title: Pointer members initialization best practices in C++98
body: <p>Assume we have the following very simple class:</p>
  
  <pre><code>class Item {
   public: 
      Item(){};
      virtual ~Item(){};
  };
  </code></pre>
  
  <p>and the class <code>ItemHolder</code> which holds a pointer to an instance of <code>Item</code>. I want <code>ItemHolder</code> to only hold a pointer to the actual data and not copy anything internally. Therefore, I guess this is how <code>ItemHolder</code> should look like:</p>
  
  <pre><code>class ItemHolder {
  public:
      ItemHolder(){
          Q = NULL;
      }
  
      ItemHolder(Item &amp;QQ){
          Q = &amp;QQ;
      }
  
      virtual ~ItemHolder() {
          // Don't delete Q!
          // The caller is responsible for the fate of Q...
      }
  
  private:
      Item *Q; 
  
  };
  </code></pre>
  
  <p>However, I guess that this design suffers from certain pathologies which in C++11 are handled with <em>smart pointers</em>. For instance one could expect that the following code would delete <code>a</code> as well, but this is not the case:</p>
  
  <pre><code>Item *a = new Item();
  ItemHolder *q = new ItemHolder(*a);      
  delete q; 
  </code></pre>
  
  <p>What is more, I more often than not meet the following constructor pattern:</p>
  
  <pre><code>ItemHolder(const Item &amp;QQ){
    Q = new Item(QQ);
  }
  </code></pre>
  
  <p>accompanied by a destructor like this:</p>
  
  <pre><code>virtual ~ItemHolder() {
    if (Q != NULL){
      delete Q;
      Q = NULL;
    }
  }
  </code></pre>
  
  <p>All this may (and will) create ambiguity regarding who is responsible for the memory management of the various objects. What are the commonly employed best practices when it comes to instantiating pointers in C++98 (given that I don't want to create any copies of other variables using <code>new</code> or a copy-constructor)?</p>