#include <iostream> class Base{private: Base() {} friend class Derived1; friend class Derived2;}; class Derived1 : public Base{}; class Derived2 : public Base{}; int main() { Derived1 obj; Base obj2; // Error return 0;}
Standard input is empty
prog.cpp: In function ‘int main()’: prog.cpp:6:2: error: ‘Base::Base()’ is private Base() {} ^ prog.cpp:22:7: error: within this context Base obj2; // Error ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!