How should a contructor handle a failure?

How should a constructor handle a failure?

- If construction fails at the runtime, it throws an exception.
- Constructor does not have return type, not even void. So, it is difficult to use return codes.
- Throws an exception is the best method to handle a failure constructor.
- If sometimes you cannot throw an exception just because of some reason, then there is another alternative to mark the object as a zombie.
What are shallow and deep copy?
What are shallow and deep copy? - A shallow copy just copies the values of the data as they are. Even if there is a pointer that points..
What is virtual constructors/destructors?
What is virtual constructors/destructors? - The explicit destroying of object with the use of delete operator to a base class pointer to the object...
When should we use container classes instead of arrays? - C++
When should we use container classes instead of arrays? - It is advisable to use container classes of the STL so that you don’t have to go through the pain of writing...
Post your comment