Tuesday, November 16, 2010

Access Specifiers

The following code does not compile:

   struct MyStruct {int i;};
   class MyClass : MyStruct {public: int i;};
   int main() {
      MyClass c1;
      c1.MyStruct::i = 44;
      return 0;
   }

The default access specifier for a class is private.

No comments:

Post a Comment