Giter Site home page Giter Site logo

Comments (3)

knatten avatar knatten commented on July 17, 2024 1

Thanks for those clarifications @bogiord! I've updated the answer now with your suggested wording, plus some references to the standard: http://cppquiz.org/quiz/question/17?result=OK&answer=abBA&did_answer=Answer

from cppquiz.

knatten avatar knatten commented on July 17, 2024

Thanks a lot for taking the time to notify me! The answer is now fixed: http://cppquiz.org/quiz/question/17?result=OK&answer=abBA&did_answer=Answer

from cppquiz.

bogiord avatar bogiord commented on July 17, 2024

There are no inherited constructors in the example. Changing "inherited constructor" to "derived class constructor" would be better, I think, but still not strictly correct. According to [class.base.init]/13, the initialization of bases is part of the execution of a derived class constructor, not something that happens before it. I guess a strict wording could be:

  • The base class is initialized (by calling its constructor) before the compound-statement of the derived class constructor body is executed.

or (this sounds better to me - it emphasizes who's in control):

  • The derived class constructor first calls the base class constructor, and then executes the compound-statement of its own body.

(The body of the constructor includes the ctor-initializer, hence compound-statement to strictly specify what gets executed.)

Also, "inherited destructor" -> "derived class destructor", but see [class.dtor]/9 - it's the same problem. I'd say:

  • The body of the derived class destructor is executed before the base class destructor.

or

  • The derived class destructor first executes its own body, and then calls the base class destructor.

(The quotes are from the latest draft, but the paragraphs haven't changed since C++11, except for a tiny correction for destructors.)

from cppquiz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.