Fill in Order Details

  • Submit paper details for free using our simple order form

Make Payment Securely

  • Add funds to your account. There are no upfront payments. The writer will only be paid once you have approved your paper

Writing Process

  • The best qualified expert writer is assigned to work on your order
  • Your paper is written to standard and delivered as per your instructions

Download your paper

  • Download the completed paper from your online account or your email
  • You can request a plagiarism and quality report along with your paper

c cs210 lab stl lists 1

The goal 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)_x000D_
  • Push the current student into the list (“students”)
  • 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_x000D_
 of type 'DataType' (or there is no acceptable conversion)_x000D_
  • Notice that the compiler is complaining about the ‘<<‘. You are trying to output a DataType but, there is no existing definition for cout << DataType.
  • Solve this problem by overloading the “<<” operator.
  • Because the packets haven’t been sorted yet, your output should look like the following:
Jacob Anderson_x000D_
Michael Thomson_x000D_
Joshua Smith_x000D_
Mathew Matheis_x000D_
Ethan Evans _x000D_
Emily Drake_x000D_
Emma Patterson_x000D_
Madison McPhee_x000D_
Hannah Briens_x000D_
Ashley Schmidt_x000D_
Press any key to continue_x000D_
  • Add code to sort the list (students), and print the correctly ordered list of students (using the iterator).
  • Build and run the executable. If you get this error:
error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &, _x000D_
const std::list<_Ty,_Alloc> &)' : could not deduce template argument for _x000D_
'const std::list<_Ty,_Alloc> &' from 'DataType'_x000D_
  • Reread the description of sort. This error is complaining about the following comparison in the sort function: DataType < DataType
  • When you correct this problem, consider using getKey(). Why?
  • (later, if you wanted to sort by firstname, how would you do it?)
  • Your output should look like the following:
Jacob Anderson_x000D_
Michael Thomson_x000D_
Joshua Smith_x000D_
Mathew Matheis_x000D_
Ethan Evans_x000D_
Emily Drake_x000D_
Emma Patterson_x000D_
Madison McPhee_x000D_
Hannah Briens_x000D_
Ashley Schmidt_x000D_
Sorting........._x000D_
Jacob Anderson_x000D_
Hannah Briens_x000D_
Emily Drake_x000D_
Ethan Evans_x000D_
Mathew Matheis_x000D_
Madison McPhee_x000D_
Emma Patterson_x000D_
Ashley Schmidt_x000D_
Joshua Smith_x000D_
Michael Thomson_x000D_
Press any key to continue_x000D_

————————————————————————————————————————–

main.cpp

#include <iostream>_x000D_
#include <fstream>_x000D_
#include <string>_x000D_
#include <list>_x000D_
_x000D_
using namespace std;_x000D_
_x000D_
struct DataType _x000D_
{_x000D_
	string lastname;	// Student's Last Name_x000D_
	string firstname;	// Student's First Name_x000D_
_x000D_
	string getKey () const_x000D_
	{ return lastname; }   // Returns the key field_x000D_
};_x000D_
_x000D_
//---------Need to add code to overload operator <<_x000D_
//------- Need to add code to fix error C2784: 'bool __cdecl std::operator <_x000D_
_x000D_
bool operator < (DataType lhs, DataType rhs)_x000D_
{_x000D_
_x000D_
}_x000D_
_x000D_
void main() _x000D_
{_x000D_
	ifstream studentFile ("input.txt");  // Student file_x000D_
	list <DataType> students;            // Students_x000D_
	DataType currStudent;              // One Student (has firstname,lastname)_x000D_
	// Read each line from input.txt:_x000D_
    //Store the firstname and the lastname into _x000D_
    //the temporary student structure "currStudent"._x000D_
	// Push the current student into the list ("students") _x000D_
	// Use an iterator to print the unsorted list of students._x000D_
	// Sort the list of students._x000D_
	// Use an iterator to print the sorted list of students._x000D_
}

WHAT OUR CURRENT CUSTOMERS SAY

  • Google
  • Sitejabber
  • Trustpilot
Zahraa S
Zahraa S
Absolutely spot on. I have had the best experience with Elite Academic Research and all my work have scored highly. Thank you for your professionalism and using expert writers with vast and outstanding knowledge in their fields. I highly recommend any day and time.
Stuart L
Stuart L
Thanks for keeping me sane for getting everything out of the way, I’ve been stuck working more than full time and balancing the rest but I’m glad you’ve been ensuring my school work is taken care of. I'll recommend Elite Academic Research to anyone who seeks quality academic help, thank you so much!
Mindi D
Mindi D
Brilliant writers and awesome support team. You can tell by the depth of research and the quality of work delivered that the writers care deeply about delivering that perfect grade.
Samuel Y
Samuel Y
I really appreciate the work all your amazing writers do to ensure that my papers are always delivered on time and always of the highest quality. I was at a crossroads last semester and I almost dropped out of school because of the many issues that were bombarding but I am glad a friend referred me to you guys. You came up big for me and continue to do so. I just wish I knew about your services earlier.
Cindy L
Cindy L
You can't fault the paper quality and speed of delivery. I have been using these guys for the past 3 years and I not even once have they ever failed me. They deliver properly researched papers way ahead of time. Each time I think I have had the best their professional writers surprise me with even better quality work. Elite Academic Research is a true Gem among essay writing companies.
Got an A and plagiarism percent was less than 10%! Thanks!

ORDER NOW


Consider Your Assignments Done

“All my friends and I are getting help from eliteacademicresearch. It’s every college student’s best kept secret!”

Jermaine Byrant
BSN

“I was apprehensive at first. But I must say it was a great experience and well worth the price. I got an A!”

Nicole Johnson
Finance & Economics

Our Top Experts

See Why Our Clients Hire Us Again And Again!


OVER

10.3k
Reviews

RATING
4.89/5
Average

YEARS
13
Mastery

Success Guarantee

When you order form the best, some of your greatest problems as a student are solved!

Reliable

Professional

Affordable

Quick

Using this writing service is legal and is not prohibited by any law, university or college policies. Services of Elite Academic Research are provided for research and study purposes only with the intent to help students improve their writing and academic experience. We do not condone or encourage cheating, academic dishonesty, or any form of plagiarism. Our original, plagiarism-free, zero-AI expert samples should only be used as references. It is your responsibility to cite any outside sources appropriately. This service will be useful for students looking for quick, reliable, and efficient online class-help on a variety of topics.