documentation - Differentiation between const and non-const versions of methods in C++ -
I have some questions about the discrimination between the const and non-const versions of the methods in C ++.
MyObject * MyClass :: objectReference () const
My questions are:
- Did the difference between the version of this method Any way is called manually? Or is it completely / fully automated and if so, what version should be called to decide precise rules? (1) If you can not differentiate between calling (1), the constable version is made of non-current version, is it impossible to call a version of a method to prevent duplication?
-
How to create a link to a version or another in the document Doxygen one of the methods used? (For example, the "version of myMethod method") or "mymethod ().")I got it - just add or empty "CONST" at the end of the method signature.
I do not know about the dosage; Although here only I know.
- If there is only one non-
const
version, then it can not be called on a singleconst
object. - If there is only one
const
version, then it can be called bothconst
and non-const
objects . - If both are, non-
const will be called non-
const
objects, and theconst
version Callers will be called on theconst
objects. - If you want to explicitly call
const
, then you must enter your object as a Constant Reference:static_cast & lt; Const MyClass & amp; & Gt; (MyObject) .bjectReference ();
Comments
Post a Comment