Should I use 'delete' in the following example?
int main(){
T object;
T* pointer = new T[4];
delete[] pointer; // this line is redudant? or error?
pointer = &object;
}
I'm asking Chat GPT this same question and it says: "the line delete is redudant and may lead to undefined behaviour, because when you re-assign the pointer, the data on heap is automatically deallocated". But i have a doubt about this. So should I use 'delete' there?