Dynamically allocated data

Introduction

This animates a program previously used in a test in CS202

#include <iostream>
int main ()
  1. {
  2. int * p;
  3. p = new int;
  4. *p =3;
  5. int * q;
  6. q=p;
  7. cout << *p << endl;
  8. cout << *q << endl;
  9. *p = 2 * *p;
  10. cout << *p << endl;
  11. cout << *q << endl;
    	return 0;
    }//main