/* -------------------------------------------------------------------- */
/* Program Name         : TestPointers4.cpp                             */
/* Author               : Leen-Kiat Soh                                 */
/* Purpose              : This program is written to illustrate ???     */
/*                        Think about what it does!!!                   */
/* Date                 : January 18, 2007                              */
/* Version              : 1.0                                           */
/* -------------------------------------------------------------------- */

#include <iostream>

using namespace std;

int main()  {

   int* p;
   int num;
   p = new int;
   *p = 4;
   num = *p;

   cout << "after assigning 4 to *p, and then assigning *p to num ..." << endl;
   cout << "p = " << p << endl;
   cout << "num = " << &num << endl;  // what does this do?
   cout << "*p = " << *p << endl;
   cout << "num = " << num << endl;

   *p = 5;         // will this cause num's value to change? why? why not?

   cout << "after *p to 5 ..." << endl;
   cout << "p = " << p << endl;
   cout << "num = " << &num << endl;
   cout << "*p = " << *p << endl;
   cout << "num = " << num << endl;

}


