title: can't fix undefined reference to vtable
body: <p>I've been searching for a while and have found a <em>lot</em> of threads/pages that involve the problem I have, but I am not able to find</p>
  
  <ol>
  <li>An explanation of <em>why</em> this error occurs</li>
  <li>A working solution for my specific case</li>
  </ol>
  
  <p>The following is <code>Scanner.h</code>:</p>
  
  <pre><code>class BaseReader {
  
      public:
  
      virtual ~BaseReader();
  
      virtual const char* read() = 0;
      virtual long position() = 0;
      virtual long size() = 0;
      virtual void seek(long position) = 0;
  
  };
  
  class CharReader : public BaseReader {
  
      public:
  
      CharReader(const char* source);
      CharReader(const char* source, long size);
  
      ~CharReader();
  
      const char* read();
      long position();
      long size();
      void seek(long position);
  
      private:
  
      char* _source;
      long _position;
      long _size;
  
  };
  </code></pre>
  
  <p>In <code>Scanner.cpp</code> I simply implement one of the constructors of <code>CharReader</code>.</p>
  
  <p>I use Code::Blocks, but compiling it by myself results in the exact same problem.</p>
  
  <pre><code>niklas@emerald:~/git/hiterator (CPP)$ g++ main.cpp hiterator/Scanner.cpp -o main
  /tmp/cclNNwgl.o: In function `hiterator::CharReader::CharReader(char const*)':
  Scanner.cpp:(.text+0x16): undefined reference to `vtable for hiterator::CharReader'
  collect2: ld gab 1 als Ende-Status zurück
  </code></pre>
  
  <hr>
  
  <p>@qdii:</p>
  
  <pre><code>#include "Scanner.h"
  using namespace hiterator;
  
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  CharReader::CharReader(const char* source) {
      _size = strlen(source);
      _source = (char*) malloc(_size + 1);
      memcpy(_source, source, _size + 1);
  }
  </code></pre>