Xref: utzoo comp.lang.c++:12447 comp.std.c++:767 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!world!wmm From: wmm@world.std.com (William M Miller) Newsgroups: chorus.os.chorus,comp.lang.c++,comp.std.c++ Subject: Re: How can I report an error when constructor parameters are wrong. Message-ID: <1991Mar25.154302.4357@world.std.com> Date: 25 Mar 91 15:43:02 GMT References: <8862@chorus.fr> Organization: The World Public Access UNIX, Brookline, MA Lines: 17 ev@chorus.fr (Eric Valette) writes: > * I would like to have opinions about the best way to check constructor > * parameters validity and report error to caller: I think that something > * is missing in the way you can report error to user using Cfront 2.0 This is true and is one of the main motivations behind the addition of exceptions to the language. In the meantime, about the best that can be done is to add a member function that can be interrogated after allocation to ensure that the constructor succeeded; something like if (!(p = new some_class) || p->ctor_failed()) { delete p; // allowed even if p == 0 // handle cleanup } -- William M. Miller, Glockenspiel, Ltd. wmm@world.std.com