/* Program 7.1.2 from C++ Programming Lecture notes  */

/* Author: Rob Miller and William Knottenbelt
   Program last changed: 30th September 2001    */

/* This program illustrates the use of the operators "new"
   and "delete". */ 

#include <iostream>
using namespace std;

typedef int *IntPtrType; 

int main()
{
	IntPtrType ptr_a, ptr_b;	/* LINE 7 */
	
	ptr_a = new int;
	*ptr_a = 4;
	ptr_b = ptr_a;				/* LINE 11 */
		
	cout << *ptr_a << " " << *ptr_b << "\n";
	
	ptr_b = new int;
	*ptr_b = 7;					/* LINE 16 */
	
	cout << *ptr_a << " " << *ptr_b << "\n";

	delete ptr_a;
	ptr_a = ptr_b;				/* LINE 21 */
		
	cout << *ptr_a << " " << *ptr_b << "\n";
	
	delete ptr_a;				/* LINE 25 */
		
	return 0;
}


/* Output is:

4 4
4 7
7 7

*/
