A little refresher

Just a little refresher for me on indirect data access and pass by reference.


using namespace std;

void Passingbyvalue(int x);
void PassingbyReference(int *x);

int main()
	int betty = 13;
	int sandy = 13;
	int* px;                            //declaration and initialization of pointer

	// PassingbyReference(&sandy);

	px = &sandy;                             //storing address of sandy into pointer
		*px = 99;                            //indirectly made sandy equal to 99

	cout << betty << endl;
	cout << sandy << endl;

	void Passingbyvalue(int x){
		x = 99;

/**	void PassingbyReference(int *x){
		*x = 99;



On line 14 there is the declaration and initialization of the pointer x.
On line 19, the address of sandy is stored in the pointer x
On line 20, sandy is indirectly given the value of 99.

2 thoughts on “A little refresher

    • No worries! When you come over during summer I’ll teach you. Or better yet, I’ll teach you during a Google Hangout with Steven.

Leave a Reply

Your email address will not be published. Required fields are marked *