Hi all,
Please answer this question. Why the output is ACA??
In the line obj = obj+6; the 6 should have been converted to obj type but, why it is converting the obj to int type?
Please help...
#include <iostream>
using namespace std;
class Base {
public:
Base(int m_var=1):i(m_var){
cout<<"A";
}
Base(Base& Base){
cout<<"B";
i=Base.i;
}
operator int() {
cout<<"C";
return i;
}
int operator+(Base& Base)
{
cout<<"D";
return i+Base.i;
}
private:
int i;
};
int main()
{
Base obj;
obj = obj+6;
return 0;
}