Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53
//I need to change this program from using inheritance to using composition.
//Could someone please show me how? I have two other programs that I can surely do myself.
//I'm really in search of a sample.
I don't see any inheritance in your program, just a single point class. And I think that for inheritance you need to have more than one class ;)
Have you posted the entire code or is this just a part of it ?
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
You can drop the inheritance and put in the Circle class a private data member center of type point. This way you would be able to use all the methods of the Point class on the center of the circle while keeping the design of Circle class intact.
class Circle:public Point3d
{
// all the members
} ;
// with composition
class Circle
{
Point3d* pt ; // or Point3d pt, your call
// other circle members
} ;
Also read this and this .
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Thanks for the help and he links thatwas good info. Merry Christmas
AH the Christmas spirit...Merry Christmas to you too my good friend.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734