title: Better interface for a class that hide container
body: <p>I have <code>MyClass</code> that hide the container inside it, I want to control when new item is added to the container and when an item is to be deleted from container, but i don't need to control read-only operation such as getter function</p>
  
  <pre><code>class MyClass {
      protected: 
          std::vector&lt;MySubClass&gt; subclasses;
      public:
  }
  </code></pre>
  
  <p>for interfacing with the user of <code>MyClass</code>, should I implement interface function such as :</p>
  
  <p><code>addSubClass()</code>, <code>getSubClassAt(int )</code>, <code>getSubClassIndex(MySubclass )</code>, <code>delSubClass()</code>. </p>
  
  <p>or its better just return const iterator, for readonly operation : </p>
  
  <p><code>std::vector&lt;MySubClass&gt;::const_iterator getSubclassIterator()</code>;</p>
  
  <p>and provide special write-operation function such as </p>
  
  <p><code>addSubClass()</code>, <code>delSubClass()</code>. </p>
  
  <p>or is there is a better way than these?</p>