I have a simple example below that does not compile. i get the following warrning about const
Error message:
error C2662: ‘Cfoo::GetNum’ : cannot convert ‘this’ pointer from ‘const Cfoo’ to ‘Cfoo &’ Conversion loses qualifiers
class Cfoo
{
public:
bool RunMe( const Cfoo * bar ) {
int i = bar->GetNum() ;
}
int GetNum() {
return 7;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Cfoo a;
Cfoo b;
b.RunMe( &a);
return 0;
}
At first I though that had something to do with the GetNum not returning a const value. changing that did not seem to help.
What did I do wrong?, suggestion, hints, examples, links?
GetNummust promise it does not change the value of the object by making it a const member function