|
-
April 12th, 2008, 04:19 AM
#3
Re: which design is better to wrap another class instance
Thanks miteshpandey,
I think your point is if owns the Goo, using class type other than pointer/reference type is better. Right?
But how do you define or judge whether "owns" or not? In my perpective, I think it means managing the lifecycle (create and destroy), I am not sure whether you have different ideas about what means own? :-)
 Originally Posted by miteshpandey
I think it actually depends on what is Foo and what is Goo and what you are trying to achieve.
In your example the Goo object actually owns the Foo object. But if actually Foo doesn't belong to Goo and Goo only needs accessing Foo then you can use a pointer or a reference.
Pointer can also be used to get an extra level of indirection (pImpl Idiom) and to reduce compilation time.
have a good weekend,
George
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|