10. What is the value of register1.item_count, register1.total_price, register2.
ID: 3844222 • Letter: 1
Question
10. What is the value of register1.item_count, register1.total_price, register2.item_ count, and register2.total_price after these statements?
CashRegister register1;
register1.clear();
register1.add_item(0.90);
register1.add_item(0.95);
CashRegister register2;
register2.clear();
register2.add_item(1.90);
11. What is wrong with this code segment?
CashRegister register2;
register2.clear();
register2.add_item(0.95);
cout << register2.total_price << endl;
12. Consider a class Time that represents a point in time, such as 9 a.m. or 3:30 p.m.
Give two different sets of data members that can be used for implementing the Time class.
13. Suppose the implementor of the Time class changes from one implementation strategy to another, keeping the public interface unchanged. What do the programmers who use the Time class need to do?
14. Consider a class Grade that represents a letter grade, such as A+ or B. Give two different sets of data members that can be used for implementing the Grade class.
Explanation / Answer
10. What is the value of register1.item_count, register1.total_price, register2.item_ count, and register2.total_price after these statements?
CashRegister register1;
register1.clear();
register1.add_item(0.90);
register1.add_item(0.95);
CashRegister register2;
register2.clear();
register2.add_item(1.90);
Answer:
register1.item_count---2
register1.total_price---1.85
register2.item_ count----1
register2.total_price---1.90
11. What is wrong with this code segment?
CashRegister register2;
register2.clear();
register2.add_item(0.95);
cout << register2.total_price << endl;
Answer:
There is no error
12. Consider a class Time that represents a point in time, such as 9 a.m. or 3:30 p.m.
Give two different sets of data members that can be used for implementing the Time class.
Answer:
13. Suppose the implementor of the Time class changes from one implementation strategy to another, keeping the public interface unchanged. What do the programmers who use the Time class need to do?
as only implementation is changed but the interface is as it is.so,same interface name we will implement and the functionality is used..
14. Consider a class Grade that represents a letter grade, such as A+ or B. Give two different sets of data members that can be used for implementing the Grade class.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.