Possible Duplicate:
How do I prevent a class from being allocated via the 'new' operator? (I'd like to ensure my RAII class is always allocated on the stack.)
Suppose I define a class in the library
class Base {};
and I publish the class to the users.
And one user defines a new class
class Derived : public Base {}
The question what can I do in Base
to prevent users create an instance of Derived
on heap?
For example, this is allowed
Derived dd;
This is not
Derived* dd = new Derived();
Thanks,