Confusion about pointer object

I am a pretty experienced programmer, but there is one thing about pointers that confuses me. I will try and explain the best I can:

Normally in a function like
1
2
3
4
void func()
{
object o;
}


the object created would get destroyed when the function leaves scope.

Now, if I use a pointer and do something like

1
2
3
4
5
void func()
{
object *o = new object();
vector.push_back(o);
}


When the function leaves scope is the object destroyed in this case? Or just the pointer?
The pointer is destroyed, not the thing it points to.
Topic archived. No new replies allowed.