Inherited classes in c++
Case:
#include<iostream>
using namespace std;
class Chef {
public:
void makeChicken(){
cout << "The chef makes chicken" << endl;
}
void makeSalad(){
cout << "The chef makes salad" << endl;
}
void makeSpecialDish(){
cout << "The chef makes bbq ribs" << endl;
}
};
class ItalianChef : public Chef{
//Chef类的继承
public:
void makePasta(){
cout << "The chef makes pasta" << endl;
}
void makeSpecialDish(){
cout << "The chef makes chicken parm" << endl;
}
};
int main(){
Chef chef;
chef.makeSpecialDish();
ItalianChef italianchef;
italianchef.makeSpecialDish();
return 0;
}