title: C++'s pure virtual function implementation and header files
body: <p>I'm having some trouble implementing pure virtual functions inherited from some abstract class, when the classes in question are divided into <code>*.h</code> and <code>*.cpp</code> files. The compiler (<code>g++</code>) tells me that the derived class cannot be instantiated because of the existence of pure functions.</p>
  
  <pre><code>/** interface.h**/
  namespace ns
  {
      class Interface {
          public:
              virtual void method()=0;
      }
  }
  
  /** interface.cpp**/
  namespace ns
  {
      //Interface::method()() //not implemented here
  }
  
  /** derived.h **/
  namespace ns
  {
      class Derived : public Interface {
          //note - see below
      }
  }
  
  /** derived.cpp **/
  namespace ns
  {
      void Derived::Interface::method() { /*doSomething*/ }
  }
  
  /** main.cpp **/
  using namespace ns;
  int main()
  {
      Interface* instance = new Derived; //compiler error
  }
  </code></pre>
  
  <p>Does this mean that I have to <strong>declare</strong> the method() twice - in the Interface's <code>*.h</code> and in the <code>derived.h</code> too? Is there no other way around?</p>