#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
usingnamespace std;
class player{
public:
player(string n, int s):
name(n), score(s){}
string name;
int score;
};
player newplayer(string n, int s)
{
return player(n,s);
}
int main()
{
vector<player>players;
players.push_back(newplayer("Assassinbeast",200));
players.push_back(newplayer("Pikachu",300));
for(int i = 0; i < players.size(); ++i)
cout << players[i].name << " -> " << players[i].score << endl;
//sort(players.score.begin(), players.score.end());
for(int i = 0; i < players.size(); ++i)
cout << players[i].name << " -> " << players[i].score << endl;
char cc; cin >> cc;
return 0;
}
As you can see, i try to sort the playerclass in the vector so the player with the lowest score gets in the lowest position in the vector (players[1] should get changed to players[0]). I commented it out because its an error, but you can see what im trying to do
Ive tried to figure out how to do it, but now i give up :P need some help here :)