I have a structure/class with a member that is a pointer, let's say
struct myStruc
{
int* m_p;
}
1. Question: Where should I delete the pointer? In the destructor?
myStruct::~myStruct()
{
delete m_p;
}
2. Question: What if the pointer is assigned to an pointer array, e.g.
myStruct mS;
mS.m_p = new int[3];
Is there a nice way (no dynamic_cast or try-catch) to now if I have to do delete
or delete[]
?