title: namespaced class template inheritance in C++
body: <p>In an earlier question, I asked asked <a href="https://stackoverflow.com/questions/23725631/c-inherit-template-class/23725683">class template inheritance in C++</a>.</p>
  
  <p>I now have an extra level to add!</p>
  
  <p>Consider the following code. (Assume the member definitions are present and accurate)</p>
  
  <pre><code>namespace Game
  {
      namespace Object
      {
          template&lt;typename T&gt;
          class Packable
          {
          public:
  
              /**
               * Packs a &lt;class T&gt; into a Packet (Packet &lt;&lt; T)
               * Required for chaining packet packing
               *************************************************/
              virtual sf::Packet&amp; operator &lt;&lt;(sf::Packet&amp; packet) = 0; // Work-horse, must be defined by child-class
              friend sf::Packet&amp; operator &lt;&lt;(sf::Packet&amp; packet, T &amp;t);
              friend sf::Packet&amp; operator &lt;&lt;(sf::Packet&amp; packet, T *t);
  
              /**
               * Unpacks a &lt;class T&gt; from a Packet (Packet &gt;&gt; T)
               * Required for chaining packet unpacking
               *************************************************/
              virtual sf::Packet&amp; operator &gt;&gt;(sf::Packet&amp; packet) = 0; // Work-horse, must be defined by child-class
              friend sf::Packet&amp; operator &gt;&gt;(sf::Packet&amp; packet, T &amp;t);
              friend sf::Packet&amp; operator &gt;&gt;(sf::Packet&amp; packet, T *t);
  
              /**
               * Unpacks a &lt;class T&gt; from a Packet (T &lt;&lt;= Packet)
               * Returns the &lt;class T&gt; for convienence
               *************************************************/
              //friend T&amp; operator &lt;&lt;=(T t, sf::Packet&amp; packet); // Returning reference to cut down on copying (they're already passing us our own copy)
              friend T&amp; operator &lt;&lt;=(T &amp;t, sf::Packet&amp; packet);
              friend T* operator &lt;&lt;=(T *t, sf::Packet&amp; packet);
          };
      }
  }
  </code></pre>
  
  <p>And this Ship class inherits from Game::Object::Packable</p>
  
  <pre><code>class Ship : public Game::Object::Base&lt;Ship&gt;, public Game::Object::Packable&lt;Ship&gt;
  {
      public:
          Ship( void );
          //...
  
          // For packing and unpackinng packets
          sf::Packet&amp; operator &lt;&lt;(sf::Packet&amp; packet);
          sf::Packet&amp; operator &gt;&gt;(sf::Packet&amp; packet);
  }
  </code></pre>
  
  <p>What we're left with is the following error.</p>
  
  <pre><code>(null): "Game::Object::operator&lt;&lt;(sf::Packet&amp;, Ship*)", referenced from:
  </code></pre>
  
  <p>I've come to the conclusion that it must have something to do with the use of namespaces. What is the solution to this if I wanted to retain the namespaces?</p>
  
  <p>Here is an excerpt of the method definitions. Do I have to <code>dereference</code> the namespace? (I don't think that even means anything haha)</p>
  
  <pre><code>/**
   * Packs a &lt;class T&gt; into a Packet (Packet &lt;&lt; T)
   * Required for chaining packet packing
   *************************************************/
  template&lt;class T&gt;
  sf::Packet&amp; operator &lt;&lt;(sf::Packet&amp; packet, T *t)
  {
      // Call the actual one, but basically do nothing... this needs to be overrided
      return packet &lt;&lt; *t;
  }
  
  template&lt;class T&gt;
  sf::Packet&amp; operator &lt;&lt;(sf::Packet&amp; packet, T &amp;t)
  {
      // Call the pointer one, but basically do nothing... this needs to be overrided
      return packet &lt;&lt; &amp;t;
  }
  
  // ... other definitions etc.
  </code></pre>