#include <iostream> using namespace std; class example { private: int var; void do_something() {std::cout << "doing something" << std::endl;} }; int main() { example e; e.var = 10; }
Standard input is empty
prog.cpp: In function ‘int main()’:
prog.cpp:13:4: error: ‘int example::var’ is private within this context
e.var = 10;
^~~
prog.cpp:6:9: note: declared private here
int var;
^~~
Standard output is empty