November 1999
Intermediate to advanced
336 pages
6h 29m
English
Like inheritance, object composition raises similar performance concerns with regard to object creation and destruction. When an object is created (destroyed), all its contained member objects must be created (destroyed) as well. For instance, the Trace object discussed in the previous chapter contains a member object of class string.
class Trace
{
...
string theFunctionName;
};
When you construct an object of type Trace, the constructor invokes the string constructor to initialize the string data member. This behavior is recursive: If class A contains a member of class B and B contains a C, the constructor for A will invoke the construction of a B object which, in turn, will trigger that of a C object. Since at each level in the ...
Read now
Unlock full access