So, I have this polymorphic hierarchy:
ClassA Is not abstract, no pure virtual functions, but a few virtual functions ClassB:public ClassA Defines an extended interface for a certain type of subclass; is abstract with pure virtual functions ClassC:public ClassB Usable class, no more subclassing
In this deal, I will have ClassA and ClassC objects grouped into containers and repeating. ClassA has an unclean virtual function to perform this iteration, but it is empty using only {} ; that is, it is empty, available only if iteration occurs with ClassC , in which case it is called, otherwise it does nothing. I cannot be clean, otherwise I cannot have ClassA objects.
But to ensure that ClassC really implements this function, forcing the user of this class to do this, I make this function pure virtual in ClassB .
It is acceptable? Nothing will break if I take an unclean virtual function, make it clean, and then make it ClassC again in ClassC ?
source share