C
Chris Gordon-Smith
Hello All
I have a base class called Action_Request, and a set of classes
corresponding to different kinds of Action_Request, each of which inherits
from Action_Request. Eg:-
class Add_Molecule_Req: public Action_Request{
// ......
};
I manipulate the various derived classes polymorphically through
Action_Requests's public interface, using its virtual functions.
Currently the overriding functions in the derived classes (including the
destructor, which overrides Action_Request's virtual destructor), are
declared public.
My program compiles if I make them private, and doing this would seem to
have the advantage that these functions must then always be invoked
polymorphically through Action_Request's public interface, which is what I
want.
My questions are:-
i) Is overriding public virtual functions with private functions good
practice?
ii) Are there any disadvantages?
Chris Gordon-Smith
www.simsoup.info
I have a base class called Action_Request, and a set of classes
corresponding to different kinds of Action_Request, each of which inherits
from Action_Request. Eg:-
class Add_Molecule_Req: public Action_Request{
// ......
};
I manipulate the various derived classes polymorphically through
Action_Requests's public interface, using its virtual functions.
Currently the overriding functions in the derived classes (including the
destructor, which overrides Action_Request's virtual destructor), are
declared public.
My program compiles if I make them private, and doing this would seem to
have the advantage that these functions must then always be invoked
polymorphically through Action_Request's public interface, which is what I
want.
My questions are:-
i) Is overriding public virtual functions with private functions good
practice?
ii) Are there any disadvantages?
Chris Gordon-Smith
www.simsoup.info