Is there a way, I can force a derived class to implement an interface through a private function. What I want is the following.
class base{
private:
virtual void do_something() = 0; // This can be private/public/protected
};
The derived class MUST provide the implementation of do_something()
which is not public. As you can guess, my objective here is to make the user give an implementation of a function but make sure that the base class is the one that will call it and an object of the class derived : public base{...}
won't ever be able to call do_something()
on its own?
EDIT: Just wanted to add, the class derived : base
will be written by the user and not by me. The use case is to make sure that functions of the base class control when do_something() is called.
Aucun commentaire:
Enregistrer un commentaire