Practice mode C++

When does a C++ compiler NOT implicitly declare a default constructor for a class?

Correct answer C. When the class declares any constructor of its own

Explanation

An implicit default constructor is declared only if the class has no user-declared constructors at all. Declaring, for example, Point(int x, int y) suppresses it, so Point p; would no longer compile. You can bring it back explicitly with Point() = default;. Destructors, static members and ordinary member functions do not affect this rule.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.