Question: P5.1 Given the following student class interface, a) implement all member functions of the class, b) implement all non-member external functions of the class, and
P5.1 Given the following student class interface, a) implement all member functions of the class, b) implement all non-member external functions of the class, and c) write a main() function to generate an output similar to the sample output appeared after the class interface. Notice that not all pre- and post-conditions for functions are provided; some are intentionally left out for you to fill in.
class student
{
public:
student();
student(string, int, double);
void inputStuRec();
// prompts the user to enter name (for simplicity, last name only), credits completed and GPA
// Postcondition: Data mambers of the calling object is filled with values entered by the user
void outputStuRec();
// Postcondition: contents of the calling object is displayed in a format shown in the sample output
void setName(string& str);
// "Mutator" or "mutator function"
// Postcondition: data member name of the calling object has been set to str
void setCredits(int);
void setGPA(double);
void setStuRec(string, int, double);
bool comapreName(student& obj2);
// Name of the calling object is comapare to that of obj2
// Postcondition: if calling object > obj2, returns true; otherwise, return false
bool compareGPA(student& obj2);
// GPA of the calling object is comapare to that of obj2
// Postcondition: if calling object > obj2, returns true; otherwise, return false
void swap(student& obj2);
// Postcondition: contents of the calling object and obj2 are swapped
private:
string name; // Last name only
int credits;
double GPA;
};
// **** External functions ****
int fillStuArray(student[], int size);
// prompt the user to enter up to size (the capacity of the array) student records
// Postcondition: student array has been filled with n records with values entered by the user, where n <= size; the value of n is returned
void sortStuArrayByName(student[], int n);
// Postcondition: student array has been sorted by student name in alphabetical order
void displayStuReport(student[], int n);
// Postcondition: n student records stored in the student array are displayed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
