错误错误LNK2019:无法解析的外部符号“公用:__thiscall
问题描述:
我无法揣摩出我的错误是 我得到的消息:错误错误LNK2019:无法解析的外部符号“公用:__thiscall
Error 21 error LNK2019: unresolved external symbol "public: __thiscall ParticleAnchoredSpring::ParticleAnchoredSpring(class Vector3 *,float,float)" ([email protected]@[email protected]@@[email protected]) referenced in function "public: void __thiscall MyGameWorld::Initialize(void)" ([email protected]@@QAEXXZ) C:\Users\Foo Nuts\Dropbox\GSP321_DavidJohnson\GSP321_Johnson_HM2\iLab2\MyGameWorld.obj
函数声明:
ParticleForceRegistry registry;
ParticleAnchoredSpring spring(&Vector3(10, 3, 10), 10, 10);
registry.add(WMI->getListPtr()[0], &spring);
类的定义:
class ParticleAnchoredSpring : public ParticleForceGenerator
{
protected:
Vector3 *anchor;
real springConstant, restLength;
public:
ParticleAnchoredSpring(Vector3 *anchor, real springConstant, real restLength);
virtual void updateForce(Particle *particle, real time);
};
构造函数dec laration:
void ParticleAnchoredSpring::updateForce(Particle *particle, real time)
{
Vector3 force;
particle->getPosition();
force -= *anchor;
real magnitude = force.magnitude();
magnitude = (restLength - magnitude) * springConstant ;
magnitude *= springConstant;
force.normalize();
force *= -magnitude;
particle->addForce(force);
}
答
您尚未实施构造函数。你只是宣布它。添加:
ParticleAnchoredSpring::ParticleAnchoredSpring(Vector3 *_anchor, real _springConstant, real _restLength)
: anchor(_anchor), springConstant(_springConstant), restLength(_restLength)
{
}
到您的实施文件。
我假设real
定义为float
。
窗户框上的用户名是迷人的。 – paddy 2012-08-01 04:26:09