Pointers, References & Arrays





Addresses





Pointer Basics

int n ; // an int int *ptr ; // a pointer to int n = 3 ; ptr = &n ; // ptr has address of n cout << "n = " << *ptr << endl ; // use *ptr to get n *ptr = 7 ; // changes n cout << "n = " << n << endl ; // n is changed



Pointers as parameters





References





Parameter Passing by Reference





const Reference Parameters





Pointers used like arrays





Incrementing Pointers





Pointer Arithmetic





Pointers vs Arrays





Pointers and Objects





Pointers as Return Values