If I do this:
// (1.)
int* p = new int;
//...do something
delete p;
// (2.)
class sample
{
public:
sample(){}
~sample(){}
};
sample* pObj = new sample;
//...do something
delete pObj;
Then how does C++ compiler know that object following delete
is built-in data type or a class object?
My other question is that if I new
a pointer to an array of int
's and then I delete []
then how does compiler know the size of memory block to de-allocate?