Calling a base class virtual function from a derived class

You can call a base class version of a virtual function from a derived class by prefixing its name with the name of the base class. For example, if you have the following base class:

class Base
{
    public:
        virtual void method()
        {
            std::cout << "Base::method()" << "\n";
        }
        virtual ~Base()
        {
        }
};

You can call its version of method() within a derived class like this:

class Derived : public Base
{
    virtual void method()
    {
        Base::method();
        std::cout << "Derived::method()" << "\n";
    }
    virtual ~Derived()
    {
    }
};

Example program:

int main()
{
    Base *d = new Derived();
    d->method();
    delete d;
}
Base::method()
Derived::method()

Note that if the base class has inherited its version of a method, rather than implementing it, you will get the inherited version. So for example in the classes below, Parent inherits method() from Grandparent, and does not override it. If Child call’s Parent‘s version of method, the inherited one from Grandparent is called:

class Grandparent
{
    public:
        virtual void method()
        {
            std::cout << "Grandparent::method()" << "\n";
        }
        virtual ~Grandparent()
        {
        }
};

class Parent : public Grandparent
{
    public:
        virtual ~Parent()
        {
        }
};

class Child : public Parent
{
    virtual void method()
    {
        Parent::method();
        std::cout << "Child::method()" << "\n";
    }
    virtual ~Child()
    {
    }
};

Example program:

int main()
{
    Parent *p = new Child();
    p->method();
    delete p;
}
Grandparent::method()
Child::method()

See also: Calling the Base Class Constructor for how to call the base class constructor from a derived class, and Virtual Base Classes for how to call a base class method to disambiguate multiple inheritance.
See Typedef super for a handy idiom for referring to the base class.