Or you can do something like that. (another proposal ) Ctor:
MayClass :: MyClass ()
: blValidityFlag ( true )
{
try
{
//Allocate, instantiate stuff
}
catch (/*whatever you want to catch*/)
{
validityFlag = false;
}
}
// public method, can be implemented also throwing
// exception
MyClass :: IsValid ()
{
return validityFlag;
}
// then after constructor you can call a IsValid method
// if its not valid you can propagate and exception
// of coruse the best is to do a class which
// implements only Isvalid and derive your class from
// Something like IValidable interface
))
// So the usage can be
MyClass instance;
instance.Isvalid (); //can throw exception or return
//false
There are, I guess (I am sure) more another posibilities. The goal is to be allways informed what failed, and and have the track of your "error source", "error flow" ....
re
Treke