There is nothing to release. The object hasn't been constructed completely yet if the constructor throws an exception. You'll need to deallocate any dynamic memory you've allocated in the constructor before throwing, however.
No. Aside from the scope issues (obj will be an undeclared identifier because it only exists inside the try block) -- if the constructor throws an exception, then the object is not constructed and must not be used.
Also if this obj happens to be valid do I need to call destructor of this class?
You should NEVER* manually call the destructor. The compiler does that automatically. Never* call it yourself.
*The only exception is if you are using placement new to construct an object in an already allocated area of memory. In which case, you would need to manually call the destructor so you can destroy the object without freeing the space.
But you probably aren't doing that, so just don't do it
When a constructor throws an exception, the object itself is never constructed; thus, it's unsafe to access anything within the class, even member functions. If a base-class throws an exception, the construction of all derived classes (including the base-class) fail, and again, they should not be accessed. If a constructor throws an exception during an allocation request, the accumulated memory is returned back to the heap/free-store. For instance:
Here, the construction of the new Object will no doubt fail. This will cause new to return the memory it accumulated to store the object back to the heap/free-store. This behaviour prevents memory leaks.
1) A will be constructed
2) B's constructor will start, but will throw an exception
3) A will be destructed
4) Exception will be caught by the catch block
will c pointer will be valid ?
No. c will be NULL. The exception was thrown before the assignment completed, so it was never reassigned.
Remember that new needs to finish evaluating before the pointer can be assigned to c. In this case, since the exception is thrown before new completes, the assignment never happens.
Yes, c will be invalid (if NULL is invalid to you) because the base-class B throws an exception during construction. As I've said before, if a base-class (B) throws an exception during construction, all derived classes (A) will fail to construct. Consequently, new will fail to construct an object and will free the memory it accumulated for the requested object.