Consider the following situation
class A
{
public:
void someFunc() const
{
b->nonConstFunction(); //this is a non const function in the class B
}
private:
B* b;
};
In the constant function someFunc()
I can call any nonconstant method of b
and it will compile. So the function someFunc()
is somehow not a true const function. But all best practices says that one should put const
anywhere you can. Should this advice be applied also here?
May be declaring the function void someFunc()
nonconstant is more honest then void someFunc() const
. Or may be there is a more general advice to handle this kind of things?