Hi I have created an taxpayer object which has string name, and a float salary, and i store them as pointers in a vector<taxpayer*>. Can anybody tell me how to arrange the taxpayers in order of their salary size so that when i print them out it prints the taxpayer with the largest salary first and smallest last?
That looks like the general idea to me although the class attributes probably shouldn't be public. I would have written const accessor functions and kept the attributes private. Try compiling it and using it and see what happens. The name of the function is the third arg of std::sort. If it is nested within the class as a static member function then simply qualify the name with the class scope as well. There are many specific ways to accomplish this but what you are doing seems okay.