S
siddhu
If there is reference member variable in the class, why doesn't
default assignment operator work?
class A
{
int& i;
public:
A( int& ii):i(ii){}
//A& operator=(const A& a){i = a.i;}
};
int main()
{
int k =10;
A a(k);
A b(k);
a = b; //This does not compile
}
But if I uncomment my assignment operator it works. I hope default
assignment operator works the same way.
default assignment operator work?
class A
{
int& i;
public:
A( int& ii):i(ii){}
//A& operator=(const A& a){i = a.i;}
};
int main()
{
int k =10;
A a(k);
A b(k);
a = b; //This does not compile
}
But if I uncomment my assignment operator it works. I hope default
assignment operator works the same way.