I'm trying to add an object to a vector, but it's not working.
Code:
class GameClass{
public:
void makeNewPlayer(int isItBad){
if (isItBad==0){
goodPlayers.push_back(PlayerClass());
}
}
private:
vector<PlayerClass> badPlayers;
vector<PlayerClass> goodPlayers;
};
class PlayerClass{
public:
PlayerClass(int badStatus){
myLocation[0]=rand()%(N-2)+1;
myLocation[1]=rand()%(N-2)+1;
isBad=badStatus;
}
void setMyLocation(int x, int y){
myLocation[0]=x;
myLocation[1]=y;
}
void getMyLocation(int *targetLoc){
targetLoc[0]=myLocation[0];
targetLoc[1]=myLocation[1];
}
private:
int myLocation[2];
int isBad=1;
};
Error
no matching function for call to 'PlayerClass::PlayerClass()'|
From this line:
goodPlayers.push_back(PlayerClass());
edit: how can i make it default constructor???
PlayerClass()declared and defined to get this working.