El resultado de la prueba debería de ser: 620 pero me da 20 alguien sabe a que se debe?.
Código
class clstest { public: clstest(); virtual ~clstest(); clstest &operator +( clstest &c1 ) { clstest tmp; int i = c1; tmp = (this->sMsg + i); return tmp; } clstest &operator +( int c1 ) { clstest tmp ; int a = (this->sMsg + c1); tmp = a; return tmp; } clstest &operator = (clstest &c1) { if ( this != &c1 ) { this->sMsg = c1; } return *this; } clstest &operator = (int c1) { this->sMsg = c1; return *this; } operator int() { return sMsg; } operator double() { return (double)sMsg; } protected: private: int sMsg; }; clstest::clstest() { //ctor this->sMsg=0; } clstest::~clstest() { //dtor } int main() { clstest a; a = 45; a = a + a + 10; a = a + a + 10 + a; a = a + a; int res = a; return 0; }
Dulces Lunas!¡.