title: How to implement class composition in C++?
body: <p>If I understand correctly we have at least two different ways of implementing composition. (The case of implementation with smart pointers is excluded for simplicity. I almost don't use STL and have no desire to learn it.)</p>
  
  <p>Let's have a look at Wikipedia <a href="http://en.wikipedia.org/wiki/Object_composition" rel="nofollow noreferrer">example</a>:</p>
  
  <pre><code>class Car
  {
    private:
      Carburetor* itsCarb;
    public:   
      Car() {itsCarb=new Carburetor();}
      virtual ~Car() {delete itsCarb;}
  };
  </code></pre>
  
  <p>So, it's one way - we have a <strong>pointer to object</strong> as private member.
  One can rewrite it to look like this:</p>
  
  <pre><code>class Car
  {
    private:
      Carburetor itsCarb;
  };
  </code></pre>
  
  <p>In that case we have an <strong>object</strong> itself as private member. (By the way, am I right to call this entity an object from the terminology point of view?)</p>
  
  <p>In the second case it is not obligatory to implicitly call default constructor (if one need to call non-default constructor it's possible to do it in initializer list) and destructor. But it's not a big problem... </p>
  
  <p>And of course in some aspects these two cases differ more appreciably. For example it's forbidden to call non-const methods of Carburetor instance from const methods of Car class in the second case...</p>
  
  <p>Are there any "rules" to decide which one to use? Am I missing something? </p>