Skip to content

Declaring a private non-const method shadows a public const method.

public: foobar() const

private: foobar()

When the respective object is called in a non-const context, then the compiler will try to call the non-const method. But it is private. The calling context would have to cast the object into a const-context before being able to acces the const method. This is just inconvenient, so don't do that.

Edited by Claus-Justus Heine

Merge request reports