Question: How do I override the value returning function makeCups(int) in the below code for the inherited class function, or how do I call the base
How do I override the value returning function makeCups(int) in the below code for the inherited class function, or how do I call the base class function to the inehrited function?
This is base class with makeCups as value returning.
class coffemachine { public: virtual int makeCups(int cups);{ int coffee_needed; int water_needed; int water_per_cup = 1; coffee_needed= cups *coffee_spoons_per_cup; water_needed= cups * water_per_cup; if ( (coffee_needed < curr_coffee) && (water_needed < curr_water) ){ cout << "Ordered " << cups << " cups of coffee of strenght " << coffee_spoons_per_cup << endl; makeSingleCup(cups); cout << endl ; return 1;} else{ cout << "Ordered " << cups << " cups of coffee of strenght " << coffee_spoons_per_cup << endl; cout << "Not enough resoruces" << endl<< " " ; return 0;}
};
This is inherited class
class MilkCoffeeMachine : public coffemachine{ public: int makeCups(int cup); // this function is to override makeCups from base class };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
