Two areas of memory: stack - what we have been using for everything up until now. when function is called a chunk (stack frame) of memory is allocated for the function to keep its parameter and local variable values. when a function exits (returns) its stack frame is recycled, everything in it is unsafe and can be over- written at any time. heap - used for values that need to survive after the function that creates them exits. Heap memory can only be accessed through pointers and is obtained by using the special C++ word "new". It remains safe until explicitly recycled by using the work "delete" or the entire program ends. * is the pointer-following operator, also used when writing the type of a pointer. If p is a variable that contains a pointer, then "* p" means follow that pointer and use the value that it leads to: what p points to. int * p; creates a variable (on the stack) that can hold a pointer to an int variable. The way it is supposed to be read is that you are declaring "* p" to be an int. As "* p" means "what p points to" and we are saying "* p" is an int, that tells us that the type of p is "pointer to int". int * p = new int; p points to 4 bytes of heap memory, those four bytes could contain anything. * p = 22; now they contain 22: 00000000000000000000000000001110 cout << * p; prints 22 cout << p; prints a large hexadecimal number cout << 4 + * p; prints 26 cout << 4 * * p; prints 88 int * q = p; cout << 4 + * q; prints 26 * p = 55; cout << 4 + * p; prints 59 cout << 4 + * 1; also prints 59 delete p; the memory that stores the 55 is recycled. Do not use * p or * q again unless they are given something else to point to. int * p = new int[10]; p points to 40 bytes of heap memory, those forty bytes could contain anything. * p = 22; the first four of those 40 bytes now hold 22 * (p + 2) = 99; bytes 8 to 11 now hold 99 p[2] = 99; is absolutely the same thing delete [] p; all 40 are recycled. If new sees [ and ], the corresponding delete must too. NULL is a special value that may be stored in any pointer variable, but it is not a valid pointer. It is used to say "I'm not pointing to anything" or "no data here". int * p = NULL; This shows why NULL is useful if (p == NULL) p = new int[5]; else p[1] += 1; ------------------------ int * f(int a, int b) Do not ctreat pointers to things that already exist { int r = a + b; unless there is no alternative. The reason ... ... ... return & r; } int * x = f(3, 4); inside the function, the local variable r does cout << * x; contain 7 as expected, and the function does return a pointer to the memory that contains that 7 also as expected. But it is in stack memory and is recycled as soon as f exits. This example will almost certainly print 7 becuase nothing has happened between f's return and printing it, so the recycled memory probably hasn't been re-used yet. But another cout << * x; appearing immediately next should fail. "cout <<" is a call to a function called "cout::operator<<" in disguise, so the memory occupied by r would have been used for something else by the first "cout <<". int * f(int a, int b) This version of f would have been safe because { int * r = new int; although the variable r itself is in the stack * r = a + b; area, and r disappears when f exits, the memory ... that r points to is in the heap area so is not ... affected. return r; }