## Chapter 1

An Object-oriented Approach

### Chapter 1

Exercises

Cuchulainn

Posts: 669
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

We have squares S and rectangle R in maths and CAD. How to model them correctly and hopefully be reusable:

a. S ISA R (aka inheritance)

b R ISA S

c R HASA S (aka wrapper/composition)

d S HASA R

e develop S and R independently of each other; they may look the same but..

choices X and Y lead to the best solution; The others are an accident/nightmare waiting to happen.

The other gem is Circle, Ellipse and Arc (a piece of a C or a E). A nice trick to do write code for Circle (easy, intersections etc.). Now, for an Ellipse, transform it to a Circle, get your answer and convert back. Very elegant and completely reusable.

Question; What are X and Y?

Cuchulainn

Posts: 669
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

### Re: Chapter 1

What's about the testAssocArrayTypedef.cpp's error message?I've tried to resolve the problem in vain :
pomi

Posts: 1
Joined: Thu Apr 09, 2015 5:54 am