G
Guest
To follow up on the "copy constructor clarification thread"...
The assignment operator syntax shown previously:
MyClass% operator=(const MyClass%);
seems to have problems if you have member properties that need to be copied
from the rhs to the lhs. Since the rhs parameter is "const MyClass", you get
an error C2662 "'MyClass:rop::get' : cannot covert 'this' pointer from
'const MyClass' to 'MyClass %'" if you have code inside like
MyClass% MyClass:perator=(const MyClass %m)
{
....
prop = m.type
....
}
I can't make the get on the property return a const int. The compiler
doesn't like that either.
What's the correct syntax for an assignment operator and the copying of a
class's properties? The copy constructor doesn't have this problem since its
parameter isn't const.
-Rob
The assignment operator syntax shown previously:
MyClass% operator=(const MyClass%);
seems to have problems if you have member properties that need to be copied
from the rhs to the lhs. Since the rhs parameter is "const MyClass", you get
an error C2662 "'MyClass:rop::get' : cannot covert 'this' pointer from
'const MyClass' to 'MyClass %'" if you have code inside like
MyClass% MyClass:perator=(const MyClass %m)
{
....
prop = m.type
....
}
I can't make the get on the property return a const int. The compiler
doesn't like that either.
What's the correct syntax for an assignment operator and the copying of a
class's properties? The copy constructor doesn't have this problem since its
parameter isn't const.
-Rob