MCQs > IT & Programming > C++ > Output of the given code? #include struct shape { virtual void move() { std::cout << 'shape::move\n'; } }; struct circle : public shape { void move() { std::cout << 'circle::move\n'; } }; struct rectangle : public shape { void move() { std::cout << 'rectangle::move\n'; } }; int main() { shape *s; s = new shape(); s->move(); s = new circle(); s->move(); s = new rectangle(); s->move(); return 0; }

C++ MCQs

Given this code, what is the output? #include struct shape { virtual void move() { std::cout << "shape::move\n"; } }; struct circle : public shape { void move() { std::cout << "circle::move\n"; } }; struct rectangle : public shape { void move() { std::cout << "rectangle::move\n"; } }; int main() { shape *s; s = new shape(); s->move(); s = new circle(); s->move(); s = new rectangle(); s->move(); return 0; }

Answer

Correct Answer: shape::move circle::move rectangle::move

Explanation:

Note: This Question is unanswered, help us to find answer for this one

C++ Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

C++ Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it