I have, for example, such class:
class Base
{
public: void SomeFunc() { std::cout << "la-la-la\n"; }
};
I derive new one from it:
class Child : public Base
{
void SomeFunc()
{
// Call somehow code from base class
std::cout << "Hello from child\n";
}
};
And I want to see:
la-la-la
Hello from child
Can I call method from derived class?
Sure:
Btw since
Base::SomeFunc()is not declaredvirtual,Derived::SomeFunc()hides it in the base class instead of overriding it, which is surely going to cause some nasty surprises in the long run. So you may want to change your declaration toThis automatically makes
Derived::SomeFunc()virtualas well, although you may prefer explicitly declaring it so, for the purpose of clarity.