In Effective C++, they recommended removing having the non-const version call the const version and remove it with a const_cast. This assumes it is not a virtual function.
If they are virtual, you are best with the duplication, or having both of them call a separate private method that does the actual work.
Show differencesHistory of post edits
#1frob
Posted 25 November 2012 - 09:03 PM
In Effective C++, Sutter recommended removing having the non-const version call the const version and remove it with a const_cast. This assumes it is not a virtual function.
If they are virtual, you are best with the duplication, or having both of them call a separate private method that does the actual work.
If they are virtual, you are best with the duplication, or having both of them call a separate private method that does the actual work.