Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Food
- {
- string name;
- int calories;
- public:
- Food(string name, int calories) :name(name), calories(calories) { };
- int getCalories()
- {
- return calories;
- }
- };
- class Cake:public Food
- {
- string mainIngridient;
- public:
- Cake(string name, int calories, string mainIngridient) :Food(name, calories),
- mainIngridient(mainIngridient) {};
- string getMainIngridient()
- {
- return mainIngridient;
- }
- };
- int main()
- {
- Food mancare("burger", 500);
- Cake desert("amandina", 300, "ou");
- cout << mancare.getCalories()<<'\n';
- cout << desert.getMainIngridient() << '\n' << desert.getCalories();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement