标签: c++ operator-overloading
我有一个班级桑普。在Samp.cpp中,我可以定义/声明一个类似
Samp& operator+(Samp& other) { std::cout << "something"; return other; }
这个功能究竟是什么?我怎么称呼它?
答案 0 :(得分:11)
这实际上是一元+,您可以这样称呼它:
+
Samp s; +s; // <-- here