|
|
|
|
|
by fooker
391 days ago
|
|
Right, when construction is fallible you need a factory. Constructors are called in surprising places when running a C++ program. For example, think of a copy constructor failing somewhere far away from the code you are writing. If C++ allowed construction to fail, the control flow of propagating these errors would be tedious and invasive. Hence exceptions as the only way to fail in a construction. |
|