Exercises
1. Using the Rectangle class from Chapter 8, “Inheritance,” add an initializer method according to the following declaration. (Note: Be sure to override init to use this initializer.)
-(id) initWithWidth: (int) w andHeight: (int) h;
2. Given that you label the method developed in Exercise 1 the designated initializer for the Rectangle class, and based on the Square and Rectangle class definitions from Chapter 8, add an initializer method to the Square class according to the following declaration:
-(id) initWithSide: (int) side;
3. Add a counter to the Fraction class’s add: method to count the number of times it is invoked. How can you retrieve the value of the counter?
4. Using typedef and enumerated data types, define a type called ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access