1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include <iostream>
#include <iomanip>
#include <string>
#include "date.cpp"
using namespace std;
#ifndef COLMBRS_H
#define COLMBRS_H
class colMbr{
private:
const unsigned idNbr;
string name;
public:
colMbr(unsigned id = 0, const string& nm)
:name(nm), idNbr(id){}
//Pure Virtual Function
virtual void addClass() const = 0;
virtual void display(void) const{
cout << name << " (" << idNbr << ")"<< endl;
}
};
class Student : public colMbr{
private:
unsigned credHrs;
unsigned qualPts;
string degSought;
public:
Student(unsigned i, const string& n,
unsigned c = 0, unsigned q = 0,
const string& d = "Unspecified")
: colMbr(i, n), credHrs(c), qualPts(q), degSought(d){}
void addClass(unsigned int1, unsigned int2){
credHrs = int1;
qualPts = int2;
}
double getGPA() const{
if (credHrs == 0){
return 0;}
else{
return (double)qualPts / (double)credHrs;}
}
void display(void) const{
colMbr::display();
cout << "Degree Sought: " << degSought << endl
<< fixed << showpoint << setprecision(2)
<< "Current GPA: " << getGPA()
<< endl;
}
};
class Alumni : public colMbr, public Date{
private:
Date dateGrad;
string degree;
public:
Alumni(unsigned i, const string& n,
int m, int d, int y,
const string& deg = "Unspecified")
: colMbr(i, n), dateGrad(m, d, y), degree(deg){}
//Needed to keep class Alumni concrete?
void addClass(void) const{}
void display(void) const{
colMbr::display();
cout << degree << " "
<< "(" << dateGrad << ")"
<< endl;
}
};
#endif
|