0

Sololearn compiler works differently from codeblocks that's why in this code the delete operator doesn't work am i correct

https://code.sololearn.com/cU6KGbpZEpeI/?ref=app

26th Jul 2020, 6:26 PM
Emmanuel Abraham
3 Answers
+ 2
The delete operator does work, but it doesn't purge the memory as that would be unnecessarily time-consuming. It only tells the OS that the memory you previously allocated is now free to be distributed to other services again. Until it is actually overwritten, the old value will remain on that memory space. However, note that accessing already deleted memory is undefined behaviour, thus you can't predict what happens when you access the deleted array, and different things will happen on different platforms/ compilers. Also have a look at the following threads, which have similar topics: https://www.sololearn.com/discuss/685561/?ref=app https://www.sololearn.com/discuss/2209606/?ref=app https://www.sololearn.com/discuss/1646033/?ref=app https://www.sololearn.com/discuss/541715/?ref=app https://www.sololearn.com/discuss/1236265/?ref=app
26th Jul 2020, 6:42 PM
Shadow
Shadow - avatar
+ 1
Emmanuel Abraham I see your doubt about this goes back as far as 2 weeks+ time. Are you getting the idea having read of what Shadow had searched for you? Maybe things can work out better if you would engage more in the discussion. I didn't see any respond from you in previous threads you have on this topic. If a doubt is still unclear then it is suggested to confirm, rather than be quiet. "So this seems to be the only logical solution." What problem, solution to what? I didn't get that ... https://www.sololearn.com/Discuss/2382678/?ref=app P.S. DM doesn't work for me, I can't reply ...
26th Jul 2020, 7:55 PM
Ipang
0
Also i have the notion because i checked youtube for tutorials so this seems to be the only logical solution
26th Jul 2020, 6:27 PM
Emmanuel Abraham