A
André Gillibert
jacob navia wrote:
3] Don't mix well with traditional error codes.
As an example, read Gripe #4 at:
http://blogs.msdn.com/ericlippert/archive/2004/03/23/94651.aspx
4] Are hard to use *correctly* without exceptions.
Whenever a constructor allocates a resource whose creation mail fail, it
must signals that.
There're several ways to get it right without exceptions.
1) A zoombie flag that has to be checked explicitly just after explicit
(or implicit) object creation.
2) Making the constructor do nothing except initialize some state bits to
indicate that the object is uninitialized and then, providing a
AllocateResource() function that does the real work and returns an error
code.
Why is this not a good idea?
Constructors and destructors look great in principle, but
they are
o difficult to implement correctly. It took the C++ people 5-6
years to get it right.
o They add too much implicit code to the language. And this is
a very important point.
3] Don't mix well with traditional error codes.
As an example, read Gripe #4 at:
http://blogs.msdn.com/ericlippert/archive/2004/03/23/94651.aspx
4] Are hard to use *correctly* without exceptions.
Whenever a constructor allocates a resource whose creation mail fail, it
must signals that.
There're several ways to get it right without exceptions.
1) A zoombie flag that has to be checked explicitly just after explicit
(or implicit) object creation.
2) Making the constructor do nothing except initialize some state bits to
indicate that the object is uninitialized and then, providing a
AllocateResource() function that does the real work and returns an error
code.