Player::Player(string Playername, int nr ,Board* x)
{
imie= Playername;
number=nr;
int k;
if(nr==1)
k=0;
else k=24;
for(int i=0;i<UNITS_NUMBER;i++)
{ Unit figure(figure,i);
units[i]=figure;
units[i].move(x->getF(k));
if(nr==1)
k++;
else k--;
}
}
(它只是 Player 类的构造函数)和错误:
在构造函数中Player::Player(std::string, int, Board*)
:
没有匹配的调用函数Unit::Unit()
Player::Player(string Playername, int nr ,Board* x)
这里是定义Unit
class Unit
{
Field* place;
Unit* unit;
int name;
public:
Unit(Unit iam, int n);
void move(Field* x);
int getname(){return name;}
};
这里是定义Player
const int UNITS_NUMBER = 5;
class Player
{
Unit units[UNITS_NUMBER];
string imie;
int number;
public:
Player(string Playername, int nr, Board *x);
string getName();
void decide(Board*);
~Player();
};
如果你需要更多,请告诉我。
更改后:
class Unit
{ Field* place;
Unit* unit;
int name;
public:
Unit(int n);
void move(Field* x);
int getname();
};
和Player
Player::Player(string Playername, int nr ,Board* x)
{
imie= Playername;
number=nr;
int k;
if(nr==1)
k=0;
else k=24;
for(int i=0;i<UNITS_NUMBER;i++)
{ Unit figure(i);
units[i]=figure;
units[i].move(x->getF(k));
if(nr==1)
k++;
else k--;
}
}
还是一样的错误;/