You've answered 0 of 163 questions correctly. (Clear)
WARNING: This question has been retracted, and should not be part of new quizzes. You're on this page because you're taking an old quiz which includes this question, or have followed an old link.
Reason for retraction:
This question was too similar to http://cppquiz.org/quiz/question/160. Aside from that, it's a good question, I just had to retract one of them.
Question #189 Difficulty:
According to the C++17 standard, what is the output of this program?
#include <iostream>
struct A {
virtual int fn(int i = 5) const { return i + 1; }
};
struct B : A {
virtual int fn(int i = 7) const override { return i + 2; }
};
void run(const A& a) {
std::cout << a.fn(1) << a.fn();
}
int main() {
run(B());
}
Hint:
Can the implementation use the dynamic type of an object when determining the default argument to a function?
Problems? View a hint or try another question.
I give up, show me the answer (make 3 more attempts first).
Mode : Training
You are currently in training mode, answering random questions. Why not Start a new quiz? Then you can boast about your score, and invite your friends.
Contribute
Android app
Get Sergey Vasilchenko's CppQuiz Android app.