Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

C++ class scopes have the with problem.

   class foo {
     // int x;
     int y;
     int bar();
   };

   // in another file

   int x;

   foo::bar()  // "with whole friggin class scope ..."
   {
     return x + y;  // global ::x plus class member y
   }
Now uncomment the x in the class declaration, and the x + y now adds two class members.


Which is why C++ has a global scope operator.


Note that it's alluded to in a comment in my comment.

The scope operator is an ugly opt-in mechanism you will only use if you discover the problem.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: