#include /* this is an abstract class in C++ */ class Honkable { public: virtual void honk(int n) { for (int i = 0; i < n; i++) { std::cout << "honk!"; } std::cout << std::endl; } }; /* a concrete implementation */ class Car : public Honkable { public: virtual void honk(int n) { for (int i = 0; i < n; i++) { std::cout << "beep!"; } std::cout << std::endl; } }; void honk(Honkable *h, int n) { // honk it! h->honk(n); } int main() { Car *h1 = new Car(); // this DOES do what we want honk(h1, 5); // we "paid" for it using the "virtual" keyword }