I usually use pure virtual functions for those methods that my code should work well. Therefore, I create interfaces, and then other users implement their derived classes. Derived classes have only these virtual functions as public, and some additional methods should be implemented as private, since my code does not call them. I don’t know if this can be considered good OOP practice (is there any design template?). Anyway, my question is: Can the user overload a pure virtual function?
i.e.
class Base
{
public:
Base();
virtual ~Base();
virtual void foo(int,double)=0;
};
class Derived:
public Base
{
private:
public:
Derived();
virtual ~Derived();
virtual void foo(int, double, double);
};
The solution may be:
virtual void foo(int,double,double=0)=0;
in the base class, but it is very limited. What do you think about?
source
share