My C++ Quiz

The ultimate place for testing what you have learned



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

Question #62: Which lines below should not compile?
39% on 755 times asked

1 #include <iostream>
2
3 class Bar
4 {
5 protected:
6   static int x;
7   int y;
8 };
9
10 int  Bar::x = 33;
11
12 class Barrel : public Bar
13 {
14 public:
15   void foo(Bar* b, Barrel* d)
16   {
17     b->y = 0;
18     d->y = 0;
19     Bar::x = 0;
20     Barrel::x = 0;
21   }
22 };
23
24 int main(int argc, char** argv)
25 {
26   Barrel b;
27   b.foo(&b, &b);
28   return 0;
29 }

none
17
18
19
20
© 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