Question: 2. Given the following classes declaration: #include using namespace std; 4 class x { private: float price; int unit;/umber of unit sold protected: float totalPrice;

 2. Given the following classes declaration: #include using namespace std; 4

2. Given the following classes declaration: #include using namespace std; 4 class x { private: float price; int unit;/umber of unit sold protected: float totalPrice; 10 public: 11 //to set input price and unit 12 8] void setInput(float p, int u) { 13 price=p; unitzu} } 14 x () {} 15 16 18 19 class Y:public x { 20 private: 21 float discount; 22 23 public: 24 float getTotalPrice(){return totalPrice; } 25 8 void calTotalPrice() { 26 totalPrices (unit * price)-(unit * price . discount); 27 28 YOU 29 - YOU 30 31 (a) Identify which C++ statement(s) cause the problem when the above C++ code is compiled (5/100) (b) Explain why the problem arises (10/100) (c) Without changing the data members access specifiers in class X, show (write) the appropriate methods so that any C++ statement in class Y can access all data in class X. (10/100) (d) Show C+ + statement so that class Y has a friend function named saleInput(....) . This friend function will be used in main ( ) program to accept sales inputs include unit price, no. of unit sold and discount (Note: answer only 1 statement) (5/100) (e) Given the following main ( ) program: int main() { int size=100; Y ob[size]; float total=0; //This loop is used to accept sale input for (int i=0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!