My C++ Quiz

The ultimate place for testing what you have learned



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

Question #54: How many times is Hello World printed by this program?
56% on 922 times asked

#include <iostream>

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

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

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

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

1
2
3
code is ill-formed
undefined
© 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