I have been given an assignment to write a program that will allow the user to input infinite amount of last names, but when the user presses "1" the program will sort last names alphabetically.
So guys if you can please help. I would really appreciate you giving me the code and explaining what you have done. It will help me understand loops and strings better.
I know that you have to make a string for first name and for last name and later you have to use loops and if statements for your last name string(this came from my head ;D).
Well actually this is not my homework :D If you read my previous post I give myself tasks which will improve my performance in c++ . So I've got an idea about this and well I can't seem to do it...
Look like all you need to do is create a vector of structs. Each struct contains a string for the last name, and a string for the first name. Then, use std::sort() to sort the vector use the last name as the parameter.
OR you could make a class, and have two variables, one for each of the names, then use std::sort() to sort a vector of the objects of "Names" which you created yourself. The first way is easier.