hi!
I'm having some problems inserting data into a std::vector.
I have a class jogador that has all the variables for the players, and when i insert whose variables into the std::vector, everyone of them except for the ID are saved
I cant see why this is happening...
campo.cpp:
Code:
//inserts data into vector
guardaRedes gr(1,0,0,"1");
gr = c1.insereGR(c1, c1.getEq1().getNome(),c1.getEq1().getNomeMCampo());
c1.getEq1().insere(&gr); //doesn't insert player ID
c1.campoJogo[gr.getPosL()][gr.getPosC()]=gr.getID();
jogador.h
Code:
class jogador
{
unsigned int numero;
unsigned int posC, posL;
string ID; //this variable doesn't get saved
bool posseBola;
string nomEquipa, nomEquipaAdv;
public:
jogador(int num, unsigned int pc, unsigned int pl, string s):numero(num), posC(pc), posL(pl), ID(s){}
unsigned int getNumero();
void setNumero(unsigned int n);
unsigned int getPosC();
void setPosC(unsigned int pc);
unsigned int getPosL();
void setPosL(unsigned int pl);
string getID();
void setID(string i);
string getNomEquipa();
void setNomEquipa(string n);
string getNomEquipaAdv();
void setNomEquipaAdv(string n);
virtual ponto posicaoVaga(string campJogo[20][37], string nomeCampo)const=0;
};
equipa.h
Code:
class equipa
{
vector <jogador *> jogadores;
string nome;
unsigned int numGolosMarc;
string nomeEquipAdv;
string nomeMeioCampo;
public:
equipa()
{
}
equipa(string n)
{
nome = n;
}
void setNomeMCampo(string n);
string getNomeMCampo();
void setNome(string n);
string getNome();
void setNomeEqAdv(string n);
string getNomeEqAdv();
void setNumGolosMarc(unsigned int n);
unsigned int getNumGolosMarc();
void insere(jogador *j); //insert players to std::vector
void visualiza() const;
jogador * pesquisa(unsigned int n);
};
equipa.cpp
Code:
//function that inserts the player into the std::vector
void equipa::insere(jogador *j)
{
jogadores.push_back(j);
}
Is there something wrong with the code? Why doesn't the ID get saved in the std::vector?