#include 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() { Bird* myBird = new Swan; // Declares a pointer to a generic Bird, // and sets it pointing to a newly-created Swan. myBird->OutputName(); // This will output "a swan", not "a bird". delete myBird; return 0; }