My C++ Quiz

The ultimate place to learn C++!

Question #58: What gets printed by this program?

#include <iostream>

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

  virtual ~Shape() {}
};

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

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

  s->print();

  delete s;

  return 0; 
}