My C++ Quiz

The ultimate place for testing what you have learned



Home | Start Quiz | List of questions  | Next Question | Login / Register

Question #55: What gets printed by this program?
72% on 1003 times asked

#include <iostream>

struct Shape
{
  void print()
  {
    std::cout << "SHAPE" << std::endl;
  }
};

struct Box : public Shape
{
  void print()
  {
    std::cout << "BOX" << std::endl;
  }
};

int main(int argc, char** argv)
{
  Shape* s1 = new Box;

  s1->print();

  return 0;
}

SHAPE
BOX
undefined
code is ill-formed
unspecified
© 2007-2010, My C++ Quiz, All rights reserved.
Can you find a bug in the quiz? Can you think of a new question that would be cool to add to this site? Email us and we will take action:
email us
Other Quizes | Contributors