Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!caen!spool.mu.edu!agate!root From: positron@cosmic.berkeley.edu (Shigeki Misawa) Newsgroups: comp.lang.c++ Subject: Flagging errors while executing a Constructor. Keywords: error, constructor Message-ID: <1991Jun4.144029.5269@agate.berkeley.edu> Date: 4 Jun 91 14:40:29 GMT Sender: root@agate.berkeley.edu (Charlie Root) Reply-To: positron@cosmic.berkeley.edu (Shigeki Misawa) Distribution: usa Organization: UCB Physics Department Lines: 23 Hi! Sorry if this is a FAQ, but I was wondering what the standard practices are in detecting errors while executing a C++ constructor, since the constructor is required to have no return value. For example, if a particular class allocates a large amount of memory from free store and there is insufficient memory available, how do you detect that this has occurred from outside the class. The only thing that I can think of is having a "success" flag and a member function that returns the value of the success flag. Also, from a style viewpoint, if a class is created to act as a gateway to a file with information, should the information be transfered from the file through the constructor or with an initialization member function? Sorry if these questions seem stupid or lack the appropriate "OOP" philosophy, but this is my first major C++ project after having made several passes over Lippman's book , Boochs' book and Stroustrup's book. Thanks in advance. Shigeki Misawa UCB Physics Department