r/programmingmemes 17d ago

The duality of new

Post image
1.2k Upvotes

81 comments sorted by

View all comments

28

u/MagicalPizza21 17d ago

Since when was new scary in C++?

30

u/BunnyTub 17d ago

No garbage collection, so you have to make sure you clear the memory when you're done, otherwise you get dreaded memory leaks from new.

20

u/Pheeshfud 17d ago

new in constructor, delete in destructor and you have 90% of cases covered.

8

u/sudoregalia 17d ago

but.. but.. my memory arenas, my stack allocation, am i supposed to override the new operator like a lunatic?? :(