In the following code, we declare a simple Object class, then construct an instance of it using the new operator:
class Object
{
Object()
{
puts( "Object constructed" );
}
~Object()
{
puts( "Object destructed" );
}
};
// Invokes constructor
Object * object = new Object();
// Invokes deconstrctor
delete object;
// resets object to a null pointer
object = 0;