#include #include using namespace std; void loader(string * &w){ string *wl = new string[3]; wl[0] = "First"; wl[1] = "Second"; wl[2] = "Third"; w = wl; } void main(){ string *w; loader(w); for(int ind = 0; ind < 3; ind++){ cout << w[ind] << endl; } delete [] w; int **pi; int *i; int j = 666; i = &j; cout << "address of j "<< &j << endl; cout << "value in i " << i << endl; cout << "dereference of i " << *i << endl; cout << "address of i " << &i << endl; *i = 13; cout << "new j " << j << endl; pi = &i; **pi = 123; cout << "value in pi " << pi << endl; cout << "new j " << j << endl; int ai[5]; for(int k = 0; k < 5; k++) ai[k] = k + 1; cout << "contents of ai " << endl; for(int k = 0; k < 5; k++) cout << ai[k] << endl; //i = j; not allowed i = ai;// ai is actually the address of the first element cout << "i " << i << endl; cout << "*i = " << *i << " ai[0] = " << ai[0]<< endl; i = &ai[0];// same as i = ai cout << "i " << i << endl; i++; cout << "i++ " << i << endl; cout << "*i " << *i << endl; i = ai; for(;i < ai+5; i++) cout << *i << endl; cout << i << endl; cout << *i << endl;// invalid cout << "addresses of ai " << endl; for(k = 0; k < 5; k++) cout << &ai[k] << endl; int *ptrs_ai[5]; for(k = 0; k < 5; k++) ptrs_ai[k] = &ai[k]; cout << "array of pointers" << endl; for(k = 0; k < 5; k++) cout << ptrs_ai[k] << endl; int **p_ptrs_ai; p_ptrs_ai = ptrs_ai; cout << "single and double pointer dereference " << endl; for(; p_ptrs_ai < ptrs_ai + 5; p_ptrs_ai++) cout << *p_ptrs_ai << " " << **p_ptrs_ai << endl; }