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:

  1. 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?
  2. 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.

  1. If there is only one non- const version, then it can not be called on a single const object.
  2. If there is only one const version, then it can be called both const and non- const objects .
  3. If both are, non- const will be called non- const objects, and the const version Callers will be called on the const objects.
  4. 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

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -