My C++ Quiz

The ultimate place for testing what you have learned



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

Question #57: How many times is Hello World printed by this program?
70% on 827 times asked

#include <iostream>

struct BS
{
  BS()
  {
    std::cout << "Hello World" << std::endl;
  }
};

struct mid1 : public BS { };
struct mid2 : public BS { };
struct mid3 : public BS { };
struct mid4 : public BS { };

struct DR : public virtual mid1, public virtual mid2, public virtual mid3, public mid4 { };

int main(int argc, char** argv) 
{ 
  DR d;
  return 0; 
}

0
3
4
undefined
code is ill-formed
© 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