title: GNU compiler warning "class has virtual functions but non-virtual destructor"
body: <p>I have defined an interface in C++, i.e. a class containing only pure virtual functions.</p>
  
  <p>I want to explicitly forbid users of the interface to delete the object through a pointer to the interface, so I declared a protected and non-virtual destructor for the interface, something like:</p>
  
  <pre><code>class ITest{
  public:
      virtual void doSomething() = 0;
  
  protected:
      ~ITest(){}
  };
  
  void someFunction(ITest * test){
      test-&gt;doSomething(); // ok
      // deleting object is not allowed
      // delete test; 
  }
  </code></pre>
  
  <p>The GNU compiler gives me a warning saying:</p>
  
  <blockquote>
    <p>class 'ITest' has virtual functions but non-virtual destructor</p>
  </blockquote>
  
  <p>Once the destructor is protected, what is the difference in having it virtual or non-virtual?</p>
  
  <p>Do you think this warning can be safely ignored or silenced?</p>