Chapter 1

An Object-oriented Approach

Chapter 1

Postby Cuchulainn » Mon Mar 12, 2007 9:58 am

Exercises
User avatar
Cuchulainn
 
Posts: 668
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Cuchulainn » Mon Sep 27, 2010 9:46 pm

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?
User avatar
Cuchulainn
 
Posts: 668
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Re: Chapter 1

Postby pomi » Thu Apr 09, 2015 3:43 pm

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


Return to Introduction to C++ for Financial Engineers (Duffy)

Who is online

Users browsing this forum: No registered users and 1 guest