title: Abstract Classes and virtual methods problems: "cannot allocate an object of abstract type"
body: <p>I have this classes:</p>
  
  <pre><code>class IDescriptor
  {
  public:
  
      virtual float compare(IDescriptor *D) = 0;
  };
  
  class DescHistogram : public IDescriptor
  {
  public:
  
      vector&lt;float&gt; desc;
      DescHistogram(vector&lt;float&gt; vd);
      ~DescHistogram();
      float compare(DescHistogram *D);
      // ALL THESE FUNCTIONS ARE IMPLEMENTED IN THE SOURCE CPP FILE.
  };
  </code></pre>
  
  <p>and in some place in my code I do this initalization:</p>
  
  <pre><code>vector&lt;float&gt; hist;
  [...] // filling the vector.
  DescHistogram *myDesc = new DescHistogram(hist);
  point.setDescriptor(myDesc);
  </code></pre>
  
  <p>The compiler gives me the following error:</p>
  
  <pre><code>error: cannot allocate an object of abstract type ‘DescHistogram’
  note:   because the following virtual functions are pure within ‘DescHistogram’:
  note:   virtual float IDescriptor::compare(IDescriptor*)
  </code></pre>
  
  <p>I have some questions about this:</p>
  
  <p>What is the reason of this error? 
  What type must be the parameter of <code>DescHistogram::compare</code>? I understand that it can be a derived type, isn't it?
  A constructor is needed by the abstract class <code>IDescriptor</code>?</p>
  
  <p>Maybe it's an stupid error, but I didn't find any solution for my case. Thanks in advance for your help!</p>