C ++如何重载前面没有标识符的运算符

C++ How to overload an operator without an identifier before it

例如:

#include <iostream>
using namespace std;

int main(){
int a;
+a;

}

我希望重载算术加号“+”运算符,这样如果它出现在一个标识符之前(在本例中为 "a"),它将打印“Hello”,而在“+”之前没有另一个标识符"运算符,基本上不是这样的:"identifierA+identifierB ",而是这样的"+identifierB"(在本例中是"+a"),程序编译的结果是"Hello"。 这怎么可能?

在此先感谢您的帮助。

如评论中所述,C++ 不允许重载基本类型的现有运算符。您可以为用户定义的类型重载运算符,但这不是您的问题。