/**********************************************
Complete the class "Musician" to produce the following output:
Name = PK. Genre = Jazz
Name = LG. Genre = Pop
*********************************************************/
#include <iostream>
#include <string>
using namespace std;
class Human {
string name;
public:
Human (string name) : name(name) { }
string getName() { return name; }
};
class Musician : public Human {
string genre;
public:
Musician (string name, string genre) : Human(name), genre(genre){}
void print() const
{
cout<<"Name = "<< getName()<<" Genre = "<<genre << endl;
}
};
int main() {
Musician m1("PK", "Jazz");
Musician* m2 = new Musician ("LG", "Pop");
m1.print();
m2->print();
delete m2;
}
i have error at the print function..
how to print out the getName..
what is the use void print () const with void print ()???
thanks