// From: http://en.wikipedia.org/wiki/C%2B%2B
#include <iostream>

class Bird                 // the "generic" base class
{
public:
    virtual void outputName() {std::cout << "a bird";}
    virtual ~Bird() {}
};

class Swan : public Bird   // Swan derives from Bird
{ 
public:
    void outputName() {std::cout << "a swan";} // overrides virtual function
};

int main()
{
    Swan mySwan;             // Creates a swan.
    Bird& myBird = mySwan;   // Declares a reference to a generic Bird,

    // and binds it to a newly created Swan.
    myBird.outputName();     // This will output "a swan", not "a bird".

    return 0;
}

