I have a struct that contains pointers:
struct foo
{
char* f;
int* d;
wchar* m;
}
I have a vector of shared pointers to these structs:
vector<shared_ptr<foo>> vec;
vec is allocated on the stack. When it passes out of scope at the end of the method, its destructor will be called. (Right?) That will in turn call the destructor of each element in the vector. (Right?) Does calling delete foo delete just the pointers such as foo.f, or does it actually free the memory from the heap?
will delete the memory allocated to the foo structure, which includes the three pointers. But the memory pointed to by the pointers themselves will only be deleted if you implement a destructor that explicitly deletes them.