为什么要打印“operator + operator +”作为输出?我的期望是“运算符 + 双运算符 +”。有人可以对此有所了解吗?
#include<iostream>
using namespace std;
struct mydata{
int mx;
mydata(int x = 0){}
mydata operator+(const mydata& rhs){
cout<<" operator + ";
mydata temp(rhs);
return temp;
}
operator int() const{cout<<" int "; return mx; }
operator double() const{cout<" double "; return mx; }
};
int main(){
mydata d;
mydata r = d + mydata(5); // L1
5 + (double)d; // L2
d + d; // L3
}