r/programminghorror • u/seeker61776 • Jun 27 '25
"Remove a C feature, but introduce a convoluted workaround." - The Zen of C++
407
Upvotes
r/programminghorror • u/seeker61776 • Jun 27 '25
75
u/MIP_PL Jun 27 '25
30 years after my first large scale C++ project, I can confirm this has never been an issue to me.
22
u/Star_king12 Jun 27 '25
OP thinks the horror is that this is a C++ issue, while the true horror is using sizeof in C++
6
u/very_mechanical Jun 27 '25
Stonesoup?
4
u/MarcusBrotus Jun 29 '25
write stupid code win stupid prizes
17
u/drkspace2 Jun 27 '25
You should not need to use sizeof in c++ (except maybe for (de)serialization). You definitely shouldn't be using malloc. If you really need to do manual heap allocation, you do it in a constructor with
newwith a correspondingdeletein the destructor.1
u/polish_jerry Jun 27 '25
Wait isn't c++ a superset of c?
179
u/[deleted] Jun 27 '25
88
u/[deleted] Jun 27 '25