// person.h   Example base class to illustrate inheritance
// P. Conrad for CISC220, 06J

#ifndef PERSON_H
#define PERSON_H

#include <iostream>

class Person_C 
{
 public:
  Person_C(const char * const theFname,
	   const char * const theLname,
	   int theId);

  const char * const getFname() const { return  fname;  };
  const char * const getLname() const { return lname;  };
  int getId() const { return id;  };

  void setFname(const char * const theFname)  
    { // @@@ change to match code in setLname, then refactor .cc file
      delete [] fname; 
      fname=new char [strlen(theFname)] + 1;
      strcpy(fname,theFname);
    }

  void setLname(const char * const theLname)
    { delete [] lname; allocateAndCopy(lname,theLname); }

  void setId(int theId) 
    { id = theId;  };

  void print(std::ostream & out = std::cout) const;

  // big-3, because we have pointers to separate space on heap

  Person_C(const Person_C & orig);
  Person_C & operator =(const Person_C & right);
  ~Person_C();

 private:
  
  
  char * fname; // separate space on heap
  char * lname; // separate space on heap
  int id;

  // utility function--allocate and copy C-string

  void allocateAndCopy(char * &dest, const char * const src)
    { dest = new char[strlen(src) + 1]; strcpy(dest,src); }

};

// the following illustrates that the parameters to a binary operator
// don't have to be called right and left

std::ostream & operator << (std::ostream & where, 
			    const Person_C & what);



#endif
