0
当我编译我的程序,我得到: 错误LNK2019无法解析的外部功能
计划的工作,如果我评论这些部分(功能的车辆::驱动器):
if (check_position(pos, number, 1, 0))
continue;
change_position(pos, number, 1, 0);
函数的恒等式change_position & check_position (terrain.cpp):
void change_position(vehicles::position &pos, int number, int vertical, int horizontal){
pos.x[number] = pos.x[number] + vertical;
pos.y[number] = pos.y[number] + horizontal;
}
bool check_position(vehicles::position &pos, int number, int vertical, int horizontal)
{
if (pos.x[number] + vertical > MAX_SIZE || pos.x[number] + vertical < 0)
return true;
if (pos.y[number] + horizontal > MAX_SIZE || pos.y[number] + horizontal < 0)
return true;
return false;
}
函数车:: drive(mechanics.cpp),未完成但在com之后工作换货上面的代码:
void vehicles::drive(int move, vehicles::position &pos, int number)
{
int direction;
cout << "Press W,A,S,D to move or Q to quit\n\n";
while (move)
{
if (move <= 0)
break;
cin >> direction;
switch (direction)
{
case 'w':
case 'W':
if (check_position(pos, number, 1, 0))
continue;
change_position(pos, number, 1, 0);
--move;
break;
case 'q':
case 'Q':
break;
default:
cout << "Press W,A,S,D to move or Q to quit\n\n";
break;
}
}
类车辆(vehickles.h):
class vehicles{
protected:
double durability;
double velocity;
public:
vehicles(double d, double v) : durability(d), velocity(v) {}
~vehicles() {}
struct position{
vector<int> x;
vector<int> y;
}pos;
void drive(int move, position &pos, int number);
void info() { cout << durability << " " << velocity << "\n"; }
};
宣言这些功能:
void change_position(vehicles::position, int, int, int);
bool check_position(vehicles::position, int, int, int);
您应该仔细检查函数声明的签名,因为它们可能与定义不匹配。由于您没有在您的帖子中包含声明,因此我们很难判断问题是否存在,或者是否是其他问题。 – 2014-10-26 14:09:32
@CaptainObvlious我编辑了我的文章。 – Kulis 2014-10-26 14:13:09