M
Metaosp
Hi, I have a question regarding the partially constructed object. If an
exception occurs while executing object's constructor, how can I delete
the resource that might have been allocated? For example:
class Foo {};
class Bar {
public:
Bar() {
f = new Foo();
throw Exception();
}
private:
Foo *f;
};
int main() {
try {
Bar *b = new Bar();
} catch (exception e) {
// What happened to *f ? How can I delete it?
}
}
Thanks,
Metaosp
exception occurs while executing object's constructor, how can I delete
the resource that might have been allocated? For example:
class Foo {};
class Bar {
public:
Bar() {
f = new Foo();
throw Exception();
}
private:
Foo *f;
};
int main() {
try {
Bar *b = new Bar();
} catch (exception e) {
// What happened to *f ? How can I delete it?
}
}
Thanks,
Metaosp