Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  asd
Language: C/C++
Code:
#include <stdio.h>
#include <iostream>
using namespace std;
enum note {middlec,csharp,cflat};

class 

instrument{
    public:
     virtual void  play(note n) const=0;
    virtual void adjust(int)=0;
};

class 

wind:public instrument{
    public:
    void play(note b)const{
        cout<<"wind::play "<<b<<endl; };
   

         void adjust(int a){cout<<"successful completion "<<a<<endl;}
};

class percussion:public 

instrument{
    public:
    void play(note b)const{
    cout<<"percussion::play "<<b<<endl; };
     void 

adjust(int){};
};

class stringed:public instrument{
    public:
    void play(note b)const{
    

cout<<"stringed::play "<<b<<endl; };
     void adjust(int){};
};

class brass:public wind{
    public:
    

void play(note b)const{
    cout<<"brass::play "<<b<<endl; };
   };
   
class woodwind:public wind{
    

public:
    void play(note b)const{
    cout<<"woodwind::play "<<b<<endl; };
   };
   
void tune

(instrument&i){
    i.play(middlec);
};

void f(instrument&i){
    i.adjust(1);
};

instrument*a[]={
    new 

wind,
    new percussion,
    new stringed,
    new brass,
};
    
int main()
{
    wind flute;
    percussion 

drum;
    stringed violin;
    brass flugelhorn;
    woodwind recorder;
    tune(flute);
    tune(drum);
    

tune(violin);
    tune(flugelhorn);
    tune(recorder);
    f(flugelhorn);
};     
          
Comments: