class Foo {
public:
void func();
};
class Bar {
private:
Foo *foo;
public:
Bar(Foo *f) : foo(f) { }
~Bar() { foo->func(); }
};
void hoge()
{
Foo f;
Bar b(&f);
}
class Foo {
public:
void func();
};
class Bar {
private:
Foo *foo;
public:
Bar(Foo *f) : foo(f) { }
~Bar() { foo->func(); }
};
void hoge()
{
Foo f;
Bar b(&f);
}
Quote:Original post by bpoint
Are objects declared on the stack *guaranteed* to be destroyed in the reverse order that they are declared?