An unofficial, read-only Hacker News reader. Join the beta →

In C++, = default and {} are not the same constructor (opens external site)

129 points by surprisetalk 2 days ago | lemire.me | 198 comments on HN

View full thread · View on Hacker News

Comment thread (2)

  1. It's not a curse, you know. You do not HAVE to bring those practices into C++, only use the learned material to peek under the hood of C++ (not even so, but as the guy above suggested, glimpse into). If only I had a dime for every curmudgeon who took your dogmatic position and tried to scare someone away from C.

    There is no better way to understand what's going on in std::vector or std::string than writing a growable array in C and having to keep three facts straight: how much storage you own, how many elements you’re using, and who releases it. Knowing how much work the abstraction does is a damn good reason to use it.

    Replies (1)
    1. That knowledge can be acquired by teaching C++ only, and in fact it was the approach taken in my university during the 1990's already, quite forward looking.

      First Pascal for those that never coded in their life, and then C++.

      The other languages that had explicit learning material were Smalltalk, Caml Light Objective Caml, Prolog, Lisp, Algol, Miranda, Java, PL/SQL, 80x86 and MIPS Assembly.

      It was expected that the few classes where C was still used, basically UNIX kernel programming, alongside algorithms and datastructures, the knowledge to code in C would be taken from those C++ classes done during the 2nd year.

      So I hold this view for almost 30 something years now.