#include <iostream>class Base { protected: static int x;};int Base::x; class DerivedA: public Base { public: DerivedA() { x = 9; }}; class DerivedB: public Base { public: DerivedB() { std::cout << DerivedA::x; }};int main() { DerivedB b;}
Standard input is empty
prog.cpp: In constructor 'DerivedB::DerivedB()': prog.cpp:6:5: error: 'int Base::x' is protected int Base::x; ^ prog.cpp:17:32: error: within this context std::cout << DerivedA::x; ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!