I have a situation where I am getting an error and I am not sure why. I have a
class
MyClass that has a copy constructor. The class has a private member that is a
const
pointer (the pointer is constant - not what the pointer points to):
class MyClass {
public:
MyClass(const MyClass &mc); // copy constructor
private:
AnotherClass* const ptrToAnotherClass;
}
The copy constructor needs to copy the const element ptrToAnotherClass to be
complete. I
do it like this:
MyClass::MyClass(const MyClass &mc) :
ptrToAnotherClass(mc.ptrToAnotherClass)
{
// other assignments
}
This gives me an odd error:
non-static const member `AnotherClass* const ptrToAnotherClass', can't use
default
assignment operator
If I remove the const specifier from the declaration for ptrToAnotherClass, and
then move
the assignment at the copy constructor into the code (instead of doing the
"const thing"
in the initializer list), then the compile works.
Any suggestions?
Jon
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d