My C++ Quiz

The ultimate place for testing what you have learned



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

Question #23: Which lines of code below should not compile?
52% on 2111 times asked

1  struct Foo
2  {
3  };
4 
5  struct Bar
6  {
7  };
8 
9 
10 int main()
11 {
12     Foo* f = new Foo;
13 
14     Bar* b1 = f;
15     Bar* b2 = static_cast<Bar*>(f);
16     Bar* b3 = dynamic_cast<Bar*>(f);
17     Bar* b4 = reinterpret_cast<Bar*>(f);
18     Bar* b5 = const_cast<Bar*>(f);
19 
20     return 0;
21 }

14
14,15,18
14,17,18
14,15,17,18
14,15,16,18
© 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