You can always use a destructor. If you have
Code:
foo a = new foo;
boo b = new boo;
you can do something like
Code:
class ab
{
foo* a;
boo* b;
class()
{
a = new foo;
b = new boo;
}
~class()
{
delete a;
delete b;
}
};
//use like
ab myVar;
Just a general example. Depends on exactly what you want. The idea is to wrap around new/delete a class that will be statically allocated so you can use the destructor mechanism.
You also try something like
Code:
template<class T>
class ptr
{
T* p;
ptr(){p = new T;}
~ptr() {delete T;}
};
//use like
ptr<foo> f;
f.p->value = 1;
You get the general idea.
I would prefer a keyword like "breakAll" to break from nested loops.