#include #include using namespace std; class A { public: bool *var; void f (bool *var) { this->var = var; } void f2 () { this->var = false; } }; int main () { bool var = true; cout << var << endl; A obj; //pass a reference of var to function f obj.f(&var); //alter var using the function f2 obj.f2(); //output altered var, which doesn't happen ;) cout << var << endl; return 0; }