title: Encapsulation: public member vs public method
body: <p>Suppose I have a class called <code>PointerSet&lt;T&gt;</code>. It is essentially a <code>vector</code> that acts like a <code>set</code> through use of <code>std::lower_bound</code> (but how it works isn't important so I won't go into further detail).</p>
  
  <pre><code>template&lt;typename T&gt;
  class PointerSet
  {
      ...
  
  public:
      void insert(T&amp;);
      void erase(T&amp;);
      void erase(const std::vector&lt;T&gt;&amp;);
  };
  </code></pre>
  
  <p>Will having a "function tunnel" take a hit to performance? (I don't know the technical term, but it is what I call it in my mind. It is a  function calling a function with the exact same purpose in mind.) Please see <strong>Version 1</strong>.</p>
  
  <p><strong>Version 1: Create a member method</strong></p>
  
  <pre><code>...
  
  template&lt;typename T&gt;
  class Node
  {
      PointerSet&lt;T&gt; Links;
  public:
      void insertLink(T&amp; p){ Links.insert(p); }
      void eraseLink(T&amp; p){ Links.erase(p); }
      void eraseLink(const std::vector&lt;T&gt;&amp; p){ Links.erase(p); }
  };
  
  class bar;
  class foo : public Node&lt;bar&gt; { };    // now foo can insert links to bars.
  
  ...
  </code></pre>
  
  <p><strong>Version 2: Just use a public member</strong></p>
  
  <pre><code>...
  
  class bar;
  struct foo
  {
      PointerSet&lt;bar&gt; Links;    // Use Links directly
  };
  </code></pre>
  
  <p>Which of these is the best approach? I am thinking about performance <em>and</em> ease of debugging.</p>