This is a for constructors, which do non-trivial resource allocation and initialization using helper member functions in the class. Exceptions raised in such member functions should be propagated upto the constructor and not eat them. In other words, such member functions should throw exception if they can't satisfy their contract even though they provide strong exception safety guarantee. Exception propagated upto the constructor will be automatically propagated where the object is being constructed indicating failure in object construction. Otherwise, silently eating exceptions during object initialization will create an object in an inconsistent state. The scope in which it is created will never know that actually the object construction failed. If object construction can be reasonably performed even in the face of exception, then it need not be propagated out. Example, LStack: A Stack implemented as a linked-list. LStack::LStack (const LStack & s) { this->copy_all_nodes...
A blog on various topics in C++ programming including language features, standards, idioms, design patterns, functional, and OO programming.