visibility.cpp
class S { public: static int m1; protected: static int m2; private: static int m3; inline void doSomething1() { ++S::m1; // good ++S::m2; // good ++S::m3; // good } friend void doSomething2(); }; inline void doSomething2() { ++S::m1; // good ++S::m2; // good ++S::m3; // good } class D: public S { inline void doSomething3() { ++S::m1; // good ++S::m2; // good //++S::m3; // bad } }; int main() { ++S::m1; // good //++S::m2; // bad //++S::m3; // bad } int S::m1 = 0; // these lines int S::m2 = 0; // are simply int S::m3 = 0; // definitions
This code was developed by phantomotap.
Have questions about this code? Comments? Did you find a bug? Let me know! 😀
Page created by G. (George) Samaras (DIT)