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 (3)

  1. Nope, because you also want C types, that now are C++ types by virtue of using a C++ compiler, to also share similar behaviours.

    Which is why the only difference between a struct and a class, is the default access method.

    Thus that C file could be made extensible in C++, with zero code changes on the call sites.

    Replies (2)
    1. What does this have to do with anything?
    2. They could have just as easily said "C semantics are used when we know we're parsing C code" and declared that C++ code doesn't have implicit constructors. No, the decision to have constructors was made because it's what they wanted to do when the language was designed. You can't lean on "but C" as an excuse when those problems are so easily solved other ways.