In C++, = default and {} are not the same constructor (opens external site)
View full thread · View on Hacker News
To get push notifications on iPhone or iPad, add Hack and Chat to your Home Screen: tap Share → Add to Home Screen, then open the installed app and enable push in Settings.
View full thread · View on Hacker News
Replies (2)
Use of references for any non nullable pointer.
RAII for heap allocated types, eventually new/delete, leave malloc()/free() family with sizeof type math for interop with existing C code.
Prefer standard library algorithms with proper bounds checking, instead of memsomething and strsomething function family.
Preprocessor magic, when templates and constexpr are type safe, and can even be single stepped on a modern IDE.
Just some examples out of my mind.
Replies (1)
Replies (2)
Replies (1)
The point being made is that the stumbling blocks exist to be tripped over by the unsuspecting, and are not because of C.
Replies (1)
(Also, this is at least in part inherited from C. Dangling pointers themselves are due to C. And temporary expressions are just acting consistently with C semantics here.)
Replies (1)
[..] One recent real-world example by one of the authors is the following: Improving the following code:
by introducing a getter to have better encapsulation, suddenly caused the undefined behavior:This is also why I dislike the term "C/C++" when referring to them as if they were a single language. They are two distinct languages with substantially different idioms.
What I hate about C++ is that it offers a myriad of ways to accomplish the same thing, ranging from outright terrible to genuinely good. Learning C first can reinforce habits that you'll later have to unlearn.