[Code for main proggie:]
Code:
#include <string.h>
#include <iostream.h>
#include "pair.h"
class Date : public Pair {
public:
int getYear () {
return aYear;
}
Date (int day, int month, int year) {
// set attributes of pair
setNum1 (day);
setNum2 (month);
// set new attribute
aYear = year;
}
void output () {
cout << getNum1 () << "." << getNum2 () << "."
<< aYear << endl;
}
private:
int aYear; // the year
};
main () {
Date HeidiKlum (4,8,1976); // the constructor
HeidiKlum.output ();
cout << "the contents of aYear is for Heidi is" << " "
<< HeidiKlum.getYear () << endl;
};
[Code for pair.h file:]
Code:
// pair.h file
#ifndef PAIR_H__
#define PAIR_H__
class Pair {
public:
Pair (int num1, int num2);
Pair ();
void output ();
void setNum1 (int num);
void setNum2 (int num);
private:
int aNum1;
int aNum2;
};
#endif