/* 
* Code Snippets for this week
* Small programs to show bits of C and bits of C. 
* >> I've tried to put * at the start of all the comment lines.
* >> I wrote this without a compiler, so might need tweaks.  
*/

/*
* Example Association example - interface file (student.h) 
*/
#ifndef _EXAMPLE_H_
#define _EXAMPLE_H_

/* Need to see the Person interface file */
#include "Person.h"

/* : = extends */
class Student : public Person
{
private:
    static const int NAME_MAX = 32;
    char name[NAME_MAX];
    int mark;
    Address* address;
public:
    Student();
    Student(char* name, int mark); 
   ~Student();
  
    void setMark(int m);
    int getMark();

    /* get/set name has moved to the base class */

    void printStudent(Student s);
    void fillStudent(Student *s);

    /* for assocation */ 
    void setAddress(Address* a);
    Address* getAddress();
}; 

/* 
* In the implementation file 
* Note: this is only the code for getAddress/setAddress 
*/
void Student::setAddress(Address* a)
{
    this->address = a;
}

Address* Student::getAddress()
{
    return this->address;
}

/* 
* The constructor also needs modification 
* - The student class must take charge of destroying the
* address object. 
*/
Student::~Student()
{
    delete this->address;
    this->address = NULL;
}
