For example:
int main() {
Foo *leedle = new Foo();
return 0;
}
class Foo {
private:
somePointer* bar;
public:
Foo();
~Foo();
};
Foo::
First note that the code wouldn't compile; new returns a pointer to an object allocated on the heap. You need:
int main() {
Foo *leedle = new Foo();
return 0;
}
Now, since new allocates the object with dynamic storage instead of automatic, it's not going out of scope at the end of the function. Therefore it's not going to get deleted either, and you have leaked memory.