B
barcaroller
I have an object that throws an exception when the constructor fails. I
could construct it inside a try/catch block, but then the object is no
longer visible outside the block.
try
{
classA objA;
}
catch (...)
{
// handle the exception
}
objA.doStuff() // Wrong! Out of scope!
I do not want to move the rest of the program inside the try/catch block.
How do I work around this?
could construct it inside a try/catch block, but then the object is no
longer visible outside the block.
try
{
classA objA;
}
catch (...)
{
// handle the exception
}
objA.doStuff() // Wrong! Out of scope!
I do not want to move the rest of the program inside the try/catch block.
How do I work around this?