I have a class named MyInteger and this class has one data member of type int - how could a overload the operator "=" to return this integer? I am not allowed to use an accessor-method to return the integer.
data member
private:
int number;
function
int MyInteger::operator=(MyInteger myInteger) {
myInteger = this->number;
return myInteger;
}
I know this is wrong and I have tried to make a typecast but that is also wrong.
In another class I am using this integer just to print
cout << number << endl;
How do I solve this?