Problem sorting an Array.

I'm sorry to say...I am completely lost. It's been a whole semester since the last time I picked up C++, and now I cam completely clueless on what to do here.

To explain what my instructor wants us to do:

He wants us to complete an exercise by writing functions for printing out, sorting, then printing out again, elements in an array.

The array in question is a String array. -and it consists of only five cells with names. In order as is, they are:

tom, mary, ann, bill, carol

He has informed us that the assignment and relational operators are overloaded. He also doesn't tell us in what way we have to sort it, but I am assuming it will be alphabetically.

I don't need the answer so much as I need a suggestion on which direction to take.
Last edited on
. . .

That would help if I had ever used that before. I never have...
http://www.cplusplus.com/forum/beginner/60381/ ¿same class?
That link has examples ¿what you don't understand?
What I don't understand is how that would sort the array alphabetically, since the array I am going to be sorting is an array of strings and not an array of integers or anything else for that matter.
It uses operator<, and std::string defines operator< for alphabetical comparison. ;)
I just now went through the code he gave us for the exercise... std::string has not been declared.

So...What? Do I bubble sort this?
std::string has no been declared
?? Not sure what you mean here. People have given you suggestions though.

Bubble sort is one of the most inefficient sorting algorithms. It's simple, but just not good. I'd recommend in looking into some others
Include the proper headers
@ne555:

. . . I don't think the instructor wants us changing what's already there. The Exercise is like a fill in the blank kind of thing. You fill in the needed code to complete the program.

@ResidentBiscuit: Well. The other methods seem really complicated to me. We never discussed them when I took the beginner class for C++ at the community college I go to.
You will be 'adding' the headers, but you should know.
It's quite hard to work blind.
Topic archived. No new replies allowed.