I have a problem with my constructor , can't figure out why the constructor is not recognized , and why it recognize int& and not just int ?
I try to change spirit and multispirit member to reference instead of pointer but it doesn't work , any help is welcome , thanks !
class Player{
public:
int playerID;
int teamPlayerID;
int playerGamesPlayed;
int ability;
int cards;
bool goalkeeper;
const permutation_t* spirit;
const permutation_t* multSpirit;
Team* teamOfPlayer;
public:
Player(int playerID,int cards,int playerGamesPlayed,bool goalkeeper, permutation_t* spirit, permutation_t* multSpirit,int teamID,int ability):playerID(playerID),cards(cards),playerGamesPlayed(playerGamesPlayed),goalkeeper(goalkeeper),spirit(spirit),multSpirit(multSpirit),teamPlayerID(teamID),ability(ability){
teamOfPlayer = NULL;
}
The function :
StatusType world_cup_t::add_player(int playerId, int teamId,
const permutation_t &spirit, int gamesPlayed,
int ability, int cards, bool goalKeeper)
{
Player* addedPlayer = new Player(playerId,cards,gamesPlayed,goalKeeper,spirit,spirit,teamId,ability);
}

const permutation_t &where the constructor expectspermutation_t *. You need to spend some more time thinking about constness, ownership, and lifetime.add_playerandPlayer's constructor makes it more likely that you're going to make an error somewhere. Be systematic and consistent.playerId, which is the name of anint. The type of the name of an int isint&(which can convert tointas needed). This is normal -- the compiler is avoiding assumptions. Focus on the types where the difference is more than just an&(i.e. don't worry aboutX&vs.X; focus onconst X&vs.X*, for some typeX).