Question: undefin main.cpp: #include #include #include #include using namespace std; struct DataType { string lastname; // Student's Last Name string firstname; // Student's First Name string

undefinmain.cpp: #include #include #include #include using namespace std; struct DataType { stringundefinlastname; // Student's Last Name string firstname; // Student's First Name stringgetKey () const { return lastname; } // Returns the key fieldmain.cpp:

#include  #include  #include  #include  using namespace std; struct DataType { string lastname; // Student's Last Name string firstname; // Student's First Name string getKey () const { return lastname; } // Returns the key field }; //---------Need to add code to overload operator  students; // Students DataType currStudent; // One Student (has firstname,lastname) // Read each line from input.txt: //Store the firstname and the lastname into //the temporary student structure "currStudent". // Push the current student into the list ("students") // Use an iterator to print the unsorted list of students. // Sort the list of students. // Use an iterator to print the sorted list of students. } 

input.txt:

Jacob Anderson Michael Thomson Joshua Smith Mathew Matheis Ethan Evans Emily Drake Emma Patterson Madison McPhee Hannah Briens Ashley Schmidt

4. Lab Exercise Copy these files to your computer. The files: stl exercise.cpp input.txt The goal of this lab is to store the students names in an STL list and sort them based on the last name. Your primary tasks for this exercise are to edit the main.cpp file so that it does the following: 1. inputs students' names from input.txt into the STL list 2. sorts the list based on the last name 3. outputs the students' names in order Steps include: Read each line from input.txt. Store the firstname and the lastname into the temporary student structure "currStudent". Hint: You can use the following format: while( studentFile >> currStudent.firstname >> currStudent.lastname) Push the current student into the list ("students") Just to see the current contents, output the students that have been stored in the list. Hint: use the iterator like in the sample program (Section 2.2) Build and run the executable file. If you get an error like this: error C2679: binary '' : no operator defined which takes a right-hand operand of type 'DataType' (or there is no acceptable conversion) Notice that the compiler is complaining about the ' &, const std::list<_ty _alloc> &)' : could not deduce template argument for 'const std::list<_ty _alloc> &' from 'DataType' Reread the description of sort. This error is complaining about the following comparison in the sort function: DataType

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!