Simplify the index base and child classes and improve encapsulation and clarity by making fully overridden virtual member functions private
. In the child classes, this allows having only public and private members. This change also help contributors add virtual functions into the correct section. Also rename the GetName()
getters to GetIndexName()
for clarity and easier grepping/reviewing.
Some context:
A base class virtual function doesn’t need to be accessible to be overridden, but it can only be private
if fully overridden, e.g. no inherited base implementation is used by the child classes.
References:
-
https://en.cppreference.com/w/cpp/language/virtual: “Base::vf does not need to be accessible or visible to be overridden. (Base::vf can be declared private, or Base can be inherited using private inheritance.)”
-
“An implementation member should be protected if it provides an operation or data that a derived class will need to use in its own implementation. Otherwise, implementation members should be private.” - C++ Primer (Lippman, Lajoie, Moo)
-
Herb Sutter in http://www.gotw.ca/publications/mill18.htm: “Make virtual functions private, and only if derived classes need to invoke the base implementation of a virtual function, make the virtual function protected. Prefer to make interfaces non-virtual using the Template pattern.”