Question: please read carefully i need a herder to write class for lab2driver.cpp it is down bellow this is the question : i need to do
please read carefully i need a herder to write class for lab2driver.cpp it is down bellow this is the question : i need to do this lab which is to write the class for this driver in the header file and the definitions of the class and any overloaded operators in the implementation file which is that will make the program work.
For this lab, I have given you 2 files, lab2driver.cpp and lab2data.txt. What you need to do is write the definitions of the class and any overloaded operators that will make the program work.
The data file has 5 lines, and the data is in the form
firstName lastName credits gpa
Do NOT change ANYTHING in the driver!
You will send me the header file(s) and the implementation file(s)
lab2driver.cpp #include #include #include using namespace std; #include "studentType.h" //function prototype void sort(studentType[], int); const int SIZE = 5; int main() { // creating an array of studentType's studentType students[5]; //defining and opening the input file ifstream data("lab2Data.txt"); // Read the data from the file for (int pos = 0; pos < SIZE; pos++) data >> students[pos]; // sort the array by LAST name (using the given sort function) sort(students, SIZE); // printing the array for (int pos = 0; pos < SIZE; pos++) { students[pos].print(cout); cout << endl; } return 0; } //function definition void sort(studentType arr[], int s) { int index; int smallestIndex; int location; studentType temp; for (index = 0; index < s - 1; index++) { //Step a smallestIndex = index; for (location = index + 1; location < s; location++) if (arr[location] < arr[smallestIndex]) smallestIndex = location; //Step b temp = arr[smallestIndex]; arr[smallestIndex] = arr[index]; arr[index] = temp; } } LabData.txt
Paul McCartney 98 2.8 Eric Clapton 75 3.1 Joe Satriani 50 1.75 Ani DiFranco 105 2.95 Chuck Berry 24 0.25
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
