Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!usc!polyslo!ttwang From: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Newsgroups: comp.lang.c++ Subject: Re: Handling trouble in C++ Keywords: exception error Message-ID: <13767@polyslo.CalPoly.EDU> Date: 24 Aug 89 22:08:16 GMT References: <13262@well.UUCP> Reply-To: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Distribution: usa Organization: Cal Poly State University -- San Luis Obispo Lines: 23 In article <13262@well.UUCP> nagle@well.UUCP (John Nagle) writes: >In C++, unlike C, a considerable fraction of the execution can >take place implicitly, within constructors and destructors, rather >than in explicitly called functions. But there is no way for a >constructor or a destructor to signal an error condition to the >invoker. You have hit a major problem of C++, that it does not have an exception handling mechanism. The programmer has to handle errors in an ad-hoc manner. error checking in normal functions are tedious enough. And error checking in constructor and destructor are particularly nasty. You can have a variable in a class that tells if its state is in a good state. But this will cause the deferred handling of errors and an increase in complexity. > John Nagle -Thomas Wang ("I am, therefore I am." - Akira ) ttwang@polyslo.calpoly.edu