Listing 1: instrument.h -- declaring abstract class Instrument, GenericInstrument subclass, and Configuration class

 1: typedef char Note; 
 2: 
 3: class Instrument { 
 4: public: 
 5:    virtual void playNote(Note key) = 0; 
 6: }; 
 7: 
 8: class GenericInstrument : public Instrument { 
 9:    char buf[40]; // maximum size of an Instrument 
10: public: 
11:    virtual void playNote(Note key) { 
12:       this->playNote(key); // enforce late binding 
13:    } 
14: }; 
15: 
16: class Configuration { 
17: public:  
18:    //... 
19:    GenericInstrument i;  
20:    //... 
21: };