Suppose program contains the following class definition. Please please indi whet
ID: 3554323 • Letter: S
Question
Suppose program contains the following class definition. Please please indi whether the statement (a)-(e) are valid. If any one is invalid, explain why. #include kiost ream endl. using std cout using std: class Auto public void set Price (double) void set Profit (double) double get Price i private double price profit double get Profit The definitions of member functions are omitted int main Auto honda toyota double a b 0; (a) honda set Price (19999.99) toyota price 19999.99; (b) a toyota set Profit (10.0) (c) (d) b honda. get Price (e) b toyota get Profit return 0;Explanation / Answer
A) Valid , Because setPrice is public
B) Invalid because price variable is private and cannot be accessed from outside of class.
C) Invalid , Because setProfit is void type so can't return anything.
D) Valid , Because getPrice is public and returns Double.
E) Invalid, Because getProfit is private and can't be accessed outside the class.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.