Athars code is trying to be clever. In his first sample he decalres a function that takes two pointers to pointers to your A class and tests to see if the first argument is greater then the second argument, although this doesn't return anything that you can use for this purpose I think he meant to show you a technique rather then provide functional code. Also with what you have written his code won't work if you just plug it right in.
EDIT: I see what's going on now, the A_lex_lt function is supposed to be your test to see if the letters NEED to be sorted, from there you need to use an if(...) to test the return value an if true then pass to your sort function. Athar seems to be ignoring the fact that you want to use a vector which unless this is part of the assignment is just as well.
What part are you having trouble with? sort can take a custom comparison object as the third argument. If you don't pass one, operator< is used by default. See here as well: http://www.cplusplus.com/reference/algorithm/sort/
Computergeek01 wrote:
a function that takes two pointers to pointers
I'm not sure where you see any pointers.
Computergeek01 wrote:
first argument is greater then the second argument
Not quite.
Computergeek01 wrote:
although this doesn't return anything that you can use for this purpose I think he meant to show you a technique rather then provide functional code.
Why do you think so? This is actually fully functional code (when you make getName a const function, as it should be).
- First bullet, you are passing variables by address so this declares variables holding the address of what are sending the function, but you're not actually sending those variables although in the end I suppose it's the same. Man this part is hard to explain I guess I'm trying to point out why you are using the '&' symbol
- Blah! I always do that! My line should read
first argument is LESS THEN the second arguement.
- You don't actually give him a way to sort the string, the code can be hard to read for a beginner and they might expect that you've given them everything they need. A user with 10 posts may not be familiar with our policy of not handing over complete solutions in which case it can be frustrating copy and pasting what you have and not seeing results.
- I forgot that sort was a function in the algorithms library.