The code giving the problem is below. I have commented which parts give the correct output, and which not, but I do not know why, and how I should be accessing the class member data normally. I read that trying to access in a C style loop as I am isn't great, but I tried ith iterators only to be met with "error: no match for 'operator<=' (operand types are 'Player' and '__gnu_cxx::__normal_iterator >')"
class Player
{
public:
    Player() {}
    Player(double strength) {}
    virtual ~Player() {}
    double GetStrength() const {
        return Strength;
    }
    void SetStrength(double val){
        Strength = val;
    }
    int GetRanking() const{
        return Ranking;
    }
    void SetRanking(int val){
        Ranking = val;
    }
    int GetATPPoints() const{
        return ATPPoints;
    }
    void SetATPPoints(int val){
        ATPPoints = val;
    }
protected:
private:
    double Strength; //!< Member variable "Strength"
    int Ranking; //!< Member variable "Ranking"
    int ATPPoints; //!< Member variable "ATPPoints"
};
int main()
{
    vector<Player> Players(1000);
    // Player strengths are generated from a normal distribution with a mean of 5 and standard deviation of 2, with values outside the range of 0-10 discarded.
    GeneratePlayerStrengths(Players);
    sort(Players.begin(), Players.end(), SortMethod); // sort descending order
    int i=1;
    for (Player a : Players)
    {   // initialise the rank of the players according to their strength
        a.SetRanking(i);
        i++;
        cout << a.GetRanking() << endl; // returns correctly
    }
    // returns all zeros, then a random number, then more zeros
    for(int j=0;j<32;j++) {
       cout << Players[i].GetRanking() << endl;
    }
    cin.ignore(); // keep the command window open for debugging purposes.
    return 0;
}
 
     
     
     
     
     
     
    