Inheritance
Lesson 31Author : 🦒
Last Updated : November, 2017
Code
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 a special dish" << endl;
}
};
class ItalianChef : public Chef{
public:
void makePasta(){
cout << "The chef makes pasta" << endl;
}
// override
void makeSpecialDish(){
cout << "The chef makes chicken parm" << endl;
}
};
int main(){
Chef myChef();
myChef.makeChicken();
ItalianChef myItalianChef();
myItalianChef.makeChicken();
return 0;
}