#include <iostream>
using namespace std;

// prototype a function that allocates an
// array of integers and puts it into the
// pointer in main using pointer notation
void g1(int **a){
	*a = new int[5];
	
}
// prototype a function that allocates an
// array of integers and puts it into the
// pointer in main using reference notation

void g2(int* &a){
	a = new int[5];
}


// prototype a function that allocates an
// array of pointers to integers and puts it into the
// pointer in main using pointer notation
void f1(int ***a){
	*a = new int*[5];
	
}
// prototype a function that allocates an
// array of pointers to integers and puts it into the
// pointer in main using reference notation

void f2(int** &a){
	a = new int*[5];
}

void main(){
	int *y;// declaring a pointer to an array of ints
	int **x;// declaring a pointer to an array of pointers to ints
	g1(&y);
	// prove that I have an array integers
	cout << "using y from g1" << endl;
	for(int i=0;i<5;i++){
        y[i]=i;
		cout << y[i] << endl;
	}
	g2(y);
	cout << "using y from g2" << endl;
	for(int i=0;i<5;i++){
        y[i] = i;
		cout << y[i] << endl;
	}
	
	f1(&x);
	// prove that I have an array of pointers
	cout << "using x from f1" << endl;
	for(int i=0;i<5;i++){
        x[i]=new int(i);
		cout << *x[i] << endl;
	}
	f2(x);
	cout << "using x from f2" << endl;
	for(int i=0;i<5;i++){
        x[i]=new int(i);
		cout << *x[i] << endl;
	}

}