I am trying to handle situations where the constructor of an object can fail to allocate memory to some of its dynamically allocated members. How can I do this without exceptions?
eg:
A::A()
{
mem1_ = new Member1();
if (mem1_ == NULL) {
delete this;
return;
}
}
B::B()
{
a1 = new A();
if (a1 == NULL) {
delete this;
return;
}
}
Is this code block allowed? It is compiling.