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.
Wednesday, October 2, 2013
C++. How to inherit operators from int?
The short answer - nohow.
But still, exists way to use int operators for your class.
It could be reached by defining implicit convertion operator to int.
Below here is demonstrative example of implementation which is useless in real programs.
But still, exists way to use int operators for your class.
It could be reached by defining implicit convertion operator to int.
Below here is demonstrative example of implementation which is useless in real programs.
Subscribe to:
Posts (Atom)