title: Any way to prevent dynamic allocation of a class?
body: <p>I'm using a C++ base class and subclasses (let's call them A and B for the sake of clarity) in my embedded system. </p>
  
  <p>It's time- and space-critical, so I really need it to be kind of minimal.</p>
  
  <p>The compiler complains about lack of a virtual destructor, which I understand, because that can get you into trouble if you allocate a <code>B*</code>  and later delete the pointer as an instance of <code>A*</code>. </p>
  
  <p>But I'm never going to allocate any instances of this class. Is there a way I can overload <code>operator new()</code> such that it compiles if there's no dynamic allocation of either class, but causes a compiler error if an end user tries to allocate new instances of A or B? </p>
  
  <p>I'm looking for a similar approach to the common technique of "poisoning" automatic compiler copy constructors via private constructors. (e.g. <a href="http://channel9.msdn.com/Forums/TechOff/252214-Private-copy-constructor-and-private-operator-C">http://channel9.msdn.com/Forums/TechOff/252214-Private-copy-constructor-and-private-operator-C</a>)</p>