Can someone please help me in the code for inheritance.
I have created a base class Instrument deriving Wind,Percussion as derived classes with function play() and tune(). Some errors are deducted dont understand where i did wrong.Please help me with this..!!!
here is the code..
#include <iostream>
using namespace std;
enum note { middleC,Csarp,Cflat };
your what() method in Wind does NOT correctly override your what() in Instrument, as that one takes a 'note' as a parameter. In essence the compiler thinks you're trying to instantiate an abstract Instrument class.
sorry it was suppose to be a comment i made changes..!!!
the errors are:
instrument1.cpp
1 error C2259: 'Wind' : cannot instantiate abstract class
1> due to following members:
1> 'char *Instrument::what(note) const' : is abstract
1> see declaration of 'Instrument::what'
1> error C2259: 'Percussion' : cannot instantiate abstract class
1> due to following members:
1> 'char *Instrument::what(note) const' : is abstract
1> see declaration of 'Instrument::what'
1>error C2259: 'Stringed' : cannot instantiate abstract class
1> due to following members:
1> 'char *Instrument::what(note) const' : is abstract
1> see declaration of 'Instrument::what'
1> error C2259: 'Brass' : cannot instantiate abstract class
1> due to following members:
1> : see declaration of 'Instrument::what'
1> error C2259: 'Woodwind' : cannot instantiate abstract class
1> due to following members:
1> 'char *Instrument::what(note) const' : is abstract
1> see declaration of 'Instrument::what'
1> Generating Code...
1> Skipping... (no relevant changes detected)
1
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.41
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========