
/****************/
/* Good Example */
/****************/

//person.h

#ifndef PERSON_H
#define PERSON_H

class Person 
{ 
    private: 
        char * name; //defines a pointer to be returned 
        char * address; //defines a pointer to be returned  
    public: 
        Person(); //default constructor 
        Person(char *n, char *a); //constructor with parameters 
        ~Person(); //destructor
		void SetName(char *n); //mutator function 
        char * GetName(); //accessor function 
        void SetAddress(char *a); //mutator function 
        char * GetAddress(); //accessor function 
};

#endif


// person.cpp

#include "Person.h"
#include <string.h>

Person::Person() //constructor
{      
    * name = NULL; 
    * address = NULL; 
} 

Person::Person(char *n, char *a) //constructor with parameter 
{
    strcpy(name,n); 
    strcpy(address,a); 
} 

Person::~Person() //destructor, undo what the constructor did  
{}

void Person::SetName(char * n) //mutator function
{
	name = n;
}

char * Person::GetName() //accessor function
{
	return name;
}

void Person::SetAddress(char * a) //mutator function
{
	address = a;
}

char * Person::GetAddress() //accessor function
{
	return address;
}


// main.cpp

#include "Person.h"
#include <iostream.h>

void main() 
{ 
    Person a; //instance of Class Person 
    Person b("Robert","U of R"); //instance with initial data 
    a.SetName("James");
	a.SetAddress("Retallack St");
    cout<<"Name of a is "<<a.GetName()<<endl; 
    cout<<"Address of a is "<<a.GetAddress()<<endl;
    cout<<"Name of b is "<<b.GetName()<<endl; 
    cout<<"Address of b is "<<b.GetAddress()<<endl; 	
} 
