home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ for Dummies (3rd Edition)
/
C_FD.iso
/
CHAP10
/
STUDENT.H
< prev
Wrap
C/C++ Source or Header
|
1996-09-02
|
930b
|
46 lines
class Student
{
public:
Student()
{
semesterHours = 0;
gpa = 0.0;
}
~Student()
{
// whatever assets are returned here
}
//grade - return the current grade point average
float grade()
{
return gpa;
}
//hours - return the number of semester hours
int hours()
{
return semesterHours;
}
//addCourse - add another course to the studentÆs record
float addCourse(int hours, float grade);
//here we allow the grade to be changed
float grade(float newGPA)
{
float oldGPA = gpa;
//only if the new value is valid
if (newGPA > 0 && newGPA <= 4.0)
{
gpa = newGPA;
}
return oldGPA;
}
//the following members are off-limits to others
protected:
int semesterHours; //hours earned towards graduation
float gpa; //grade point average
};