When do I really need to use Delete in Destructors?
if I do Point P = new Point();
I've been told every time I use new, it stays in memory even when out of scope and that I should use delete to remove it.. so do i need to do Delete P?
The thing is, shouldn't the destructor take care of it? Also when the program terminates, wouldn't it free?
also I have:
class PA //array of P..
{
private:
vector<P> DataHolder;
public:
PA() {}
PA(P) : DataHolder.push_back(P) {}
PA(....)
{
//push back all values in the elipsis..
}
~PA()
{
//Do I need a delete in a for loop here?
}
};
P.S. what is the difference between new [] and new.. and delete [] and delete? One is for arrays?