|
|||||||||||||||||
|
Section 31:
|
[31.4] Should I normally use pointers to freestore allocated objects for my data members, or should I use "composition"?
Composition. Your member objects should normally be "contained" in the composite object (but not always; "wrapper" objects are a good example of where you want a pointer/reference; also the N-to-1-uses-a relationship needs something like a pointer/reference). There are three reasons why fully contained member objects ("composition") has better performance than pointers to freestore-allocated member objects:
|
||||||||||||||||