为了清楚起见,让我的新课程是:
class MyInt{
public:
MyInt(int x){theInt = x /10;}
int operator+(int x){return 10 * theInt + x;}
private
int theInt;
};
假设我希望能够定义:
MyInt Three(30);
int thirty = Three;
但为了得到这个结果,我正在写:
MyInt Three(30);
int thirty = Three + 0;
如何从自定义类自动转换为内置类型?