7.3.3. Class Types
Every class defines a unique type. Two different classes define two different types even if they define the same members. For example:
Exercise 7.27: Add the move
, set
, and display
operations to your version of Screen
. Test your class by executing the following code:
Screen myScreen(5, 5, 'X');myScreen.move(4,0).set('#').display(cout);cout << "\n";myScreen.display(cout);cout << "\n";
Exercise 7.28: What would happen in the previous exercise if the return type of move
, set
, and display
was Screen
rather than Screen&?
Exercise 7.29: Revise your Screen
class so that move
, set
, and display
functions return Screen
and check your prediction from the previous exercise.
Exercise 7.30: It is legal but redundant ...
Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.