K
kk_oop
Hi. I just wrote a function that returns a const pointer:
MyClass
{
....
public:
virtual ReturnClass * const getReturnClass( );
....
}
I then wrote some code that calls the function to make sure the
pointer was really const:
MyClass myClass1;
ReturnClass * myReturnClass = myClass1.getReturnClass( );
MyClass myClass2;
myReturnClass = myClass2.getReturnClass( );
I anticipated getting a compiler error when I attempted to reset
myReturnClass, but this did not happen. The compiler let me change
the value. What did I do wrong?
Thanks!
Ken
MyClass
{
....
public:
virtual ReturnClass * const getReturnClass( );
....
}
I then wrote some code that calls the function to make sure the
pointer was really const:
MyClass myClass1;
ReturnClass * myReturnClass = myClass1.getReturnClass( );
MyClass myClass2;
myReturnClass = myClass2.getReturnClass( );
I anticipated getting a compiler error when I attempted to reset
myReturnClass, but this did not happen. The compiler let me change
the value. What did I do wrong?
Thanks!
Ken