+ 1

difference between delete and overwrite for pointers in C++

Hi, As I learn about pointers, dynamic memory allocation etc. I wonder : Solo learn suggest that a dangling pointer can be re-allocated. since the pointers point toward unnamed variable, what use is there to delete the pointer, then re-allocate it a new variable of the same type on which you will store data. Wouldn't it have exactly the same effect just to overwrite the new data on the old one ?

4th Feb 2019, 2:56 PM
Etienne Wiest
Etienne Wiest - avatar
3 Answers
+ 1
In the chapter "dynamic memory" of the introduction... What... I ask to many questions at this stage ? ^^
4th Feb 2019, 5:46 PM
Etienne Wiest
Etienne Wiest - avatar
+ 1
Hmmm thx Bennett, I didn't get everything so far (didn't reach the chapter on lists or objects yet) but I feel that it will soon make sense thx to your explanations and said chapter :)
4th Feb 2019, 5:54 PM
Etienne Wiest
Etienne Wiest - avatar
+ 1
Yes, that is what I got from your answer, and since I don't know or understand those scenarii yet, I just need to move forward in the lessons :)
4th Feb 2019, 5:56 PM
Etienne Wiest
Etienne Wiest - avatar