Question: in C++ i want to write a header file and implementation file for the lab2driver.cpp down below write the class for this driver in the
in C++ i want to write a header file and implementation file for the lab2driver.cpp down below write the class for this driver in the header file and the definitions of the class and any overloaded operators in the implementation file
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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
