hi, Ive a vector of TaxPayer objects, instances of TaxPayer have an instance variable of type float call tax, I want to sort such that it lists the taxpayers in increasing order of how much tax they pay.
i've been trying stuff like sort (taxpayers.begin(), taxpayers.end());
however this throws up all sorts of errors, as i think this is only applicable to vectors of primitive datatypes....
The difference is that int already has an implicit sorting algorithm. You need to provide that to std::sort() in order to... sort. You'll probably want to sort based on some kind of ID or by name.
yeah i already know dat lol, but as asked how do u do it... i want to sort on a member variable of the TaxPayer object called tax of type float... can someone please help lol...
well sorry, but im only writting in c++ few weeks not used to pointers in java so really haven't a clue how to do that, but would appriciate dearly if u could show me how to....
lol im beginning to think its u thats simple my friend....
Im using pointers as stated many times above and not references to memory addresses so im off course already using * and ->.... now if you can only provide vauge unhelpful asides, I rather wait until 2maro when, perhaps I could get some help of someone more european (ie less condescending and actually helpfull) and to the point n less of a know it all without solutions as many americans tend to be......
anyway i sorted by creating/recreating an insertionSort method myself but would of liked to learn how to sort a vector of pointers to objects in C++
I meant replace in my example. Why would I tell you to change the references in your program to pointers if I already know you're using pointers?
I hardly think a complete working example (two if you consider that I also gave you the steps on how convert it to pointers which you could have followed had not spent your time misinterpreting my words) qualifies as a "vague unhelpful aside". I should have just posted the link to the std::sort() reference. Would that have been more helpful?
And I'm not American (not even close, really), but we don't take too kindly to this kind of faggotry, around here, either.