#include <iostream>
#include <cstdlib>
using namespace std;

int i = 10;   //statically allocated so it won't be destroyed by a return

int f();
int *g();
int& h();

int main()
{
	cout << "f() == " << f() << "\n"
		<< "*g() == " << *g() << "\n"
		<< "h() == " << h() << "\n";

	//f() = 20;   //won't compile
	*g() = 30;    //Change the value of i to 30.  Must have the asterisk.
	h() = 40;     //Change the value of i to 40.  Don't need asterisk.

	//cout << &f() << "\n";              //won't compile
	cout << &*g() << " " << g() << "\n"; //Print the address of i.
	cout << &h() << "\n";                //Print the address of i.

	return EXIT_SUCCESS;
}

int f()
{
	return i;    //Create a copy of the value of i and return the copy.
}

int *g()
{
	return &i;   //Return the address of i.
}

int& h()
{
	return i;    //Return the address of i.
}