I have a few questions regarding differentiation between const and non-const versions of methods in C++.
Example:
MyObject* MyClass::objectReference()
const MyObject* MyClass::objectReference() const
My questions are:
- Is there any way at all to differentiate between which version of the method is called manually? Or is it fully/completely automatic and if so what are the precise rules for determining which version is to be called?
- Related to (1), if you cannot differentiate between calling the const vs the non-const version, it's therefore impossible to call one version of a method from the other to prevent duplication?
How to create a link to one version or the other in the documentation of one of the methods using doxygen? (e.g. "const version of myMethod()." or "non-const version of myMethod().")Found this out myself - just add or omit " const" at the end of the method signature.