#include	"iostream.h"
#include	"string.h"

class Person
	{
	private:
		int		age;
		char		*name;
	public:
					Person(int a, char *s);
					~Person( );
		void 	display( );
		void 	assign(int a, char *s);
		void 	operator = (Person  &other_object);
		friend 	void show_older(Person  &a, Person &b);
	};

Person::Person( int a, char *s)
	{
	cout << "Creating " << s << "\n";
	age = a;
	name = new char[80];
	strcpy (name,s);
	}

Person::~Person()
	{
	cout << "Deleting " << name << "\n";
	delete name;
	name = NULL;
	}

void
Person::assign( int a, char *s)
	{
	age = a;
	if (name == NULL)
		strcpy (name,s);
	}

void
Person::display()
	{
	cout << name << " is " << age << " years old \n";
	}

void
Person:: operator = (Person &other_object)
	{
	age = other_object.age;
	strcpy(name,other_object.name);
	}

void
show_older(Person &a, Person &b)	// I am a friend of Person
	{                         // so I can access private data
	cout << "The older person is : ";
	if (a.age > b.age)
		a.display();
	else
		b.display();
	}

void
main()
	{
	Person fred(37 ,"fredy"), bill(42, "billy");
	fred.display();
	bill.display();
	show_older(bill,fred);
	bill = fred;					// Our "=", not the usual one.
	bill.display();
	bill.assign(56, "new guy");
	bill.display();
	}

