Wolfie7873
Technical User
Assuming a valid copy constructor as follows:
Class::Class(const Class& other)
{
myData=other.myData;
}
can I have this for my overloaded assignment?
Class&
Class:
perator=(const Class& rhs)
{
if (this != &rhs) {
this = new Class(rhs);
}
return *this;
}
I didn't know if I'm allowed to make direct assignments to the "this" pointer.
Thanks,
Eddie
Class::Class(const Class& other)
{
myData=other.myData;
}
can I have this for my overloaded assignment?
Class&
Class:
{
if (this != &rhs) {
this = new Class(rhs);
}
return *this;
}
I didn't know if I'm allowed to make direct assignments to the "this" pointer.
Thanks,
Eddie