#include <iostream>
using namespace std;

int x = 42;

int g(int arg) {
	cout << "g was called with argument " << arg << endl;
	return arg;
}

void f(int arg = g(x)) {
	cout << "f was called with argument " << arg << endl;
}

int main() {
	f(); // g is called the first time
	f(); // g is called again
	f(23); // g isn't called because an argument was provided
	x = 13;
	f(); // g is called again, taking the changed value of x into account
	{
		int x = 7;
		f(); // g is called again, the local x is ignored because it wasn't in
		     // scope when f was defined
	}
	return 0;
}