struct Object{
size_t num;
Object(size_t s){
num = s;
}
Object(string str){
num = 1;
}
Object& operator = (const Object& b){
cout << "assignemnt constructor called" << endl;
return *this;
}
};
int main ()
{
Object b2{ 5 };
Object b3("str");
b2 = b3;
b3 = Object(2); //<-------------how can you set b3 to be Object(2)?
}
I'm trying to set an object to be equal to a new object. but b3 doesn't change in this example. Can anyhelp help me understand how I can get b3 to be a new object(2). Thanks