Sunday, October 20, 2013

C++. How to call non-const method from const method?


There is two ways how to call non-constant method from constant method in C++:
1. Call non-const method from const_casted this pointer.
2. Use reinterpret_cast to cast pointer of non-const method to const method pointer.

The first way is more acceptable and easy.

Below here is C++ code with example of this two ways.


 

No comments:

Post a Comment