// student.cc   Example derived class
// P. Conrad for CISC220, 06J

#include "student.h"


Student_C::Student_C(const Student_C & orig) :
  Person_C(orig)
{
  allocateAndCopy(major,orig.major);
}

Student_C & Student_C::operator =(const Student_C & right)
{
  // check for self-assignment

  if (&right == this)
    return (*this);

  // invoke parent class assignment operator
  
  Person_C::operator=(right);
  
  // handle attributes specific to this subclass

  delete [] major;
  allocateAndCopy(major, right.major);
  gpa = right.gpa;
  
  // return reference to self to enable chaining (e.g. a = b = c;)

  return (*this);

}

Student_C::~Student_C()
{
  // What to do about base class destructor... @@@ ???
  // See : http://burks.bton.ac.uk/burks/language/cpp/cppfaq/dtors.htm#[11.12]

  delete [] major;
  major = NULL;
}


void Student_C::print(std::ostream & out) const
{
  Person_C::print(); out << " " << major << " " << gpa;
}

// the following illustrates that the parameters don't have to be
// right and left---here we use "where and what" instead.

std::ostream & operator << (std::ostream & where, 
			    const Student_C & what)
{
  what.print(where);
  return (where);
}




