How to implement a private virtual function within derived classes?
- by Dane
Hi,
I know why I want to use private virtual functions, but how exactly can I implement them?
For example:
class Base{
[...]
private:
virtual void func() = 0;
[...]
}
class Derived1: puplic Base{
void func()
{ //short implementation is ok here
}
}
class Derived2: puplic Base{
void func(); //long implementation elsewhere (in cpp file)
}
[...]
void Derived2::func()
{ //long implementation
}
The first version is ok but not always possible.
Isn't the second version simply name hiding? How do you define the Base::func() of Derived2, if you cannot do it within the class declaration of Dereived2?
Thanks