// demonstrates pointer manipulations with functions // Mikhail Nesterenko // 10/29/2009 #include // passing pointer by value void funcVal(int *p){ *p = 22; p = new int(33); } // passing pointer by reference void funcRef(int * &p){ *p = 44; p = new int(55); } // passing pointer to pointer void funcRefRef(int **pp){ **pp = 66; *pp = new int(77); } // returning pointer int *funcRet(){ int *tmp = new int(88); return tmp; } int main(){ int *ip1=new int(1); int *ip2=new int(1); int *ip3=new int(1); funcVal(ip1); // pass-by-value funcRef(ip2); // pass-by-reference funcRefRef(&ip3); // passing of pointer to pointer int *ip4=funcRet(); // returning a pointer }