My C++ Quiz

The ultimate place to learn C++!

Question #62: Which lines below should not compile?

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 }