I have a class without a destructor and a constructor like this:
class Foo {
public:
Foo(int a) : p(new int(a)) {}
private:
int *p;
};
{
Foo a(4);
}
After this block of code will the memory allocated on the heap be released ? Or do i have to explicitly provide a destructor like this:
class Foo {
public:
Foo(int a) : p(new int(a)) {}
~Foo();
private:
int *p;
};
Foo::~Foo() {
delete p;
}