我无法弄清楚我的错误在哪里。 我收到了消息:
Error 21 error LNK2019: unresolved external symbol "public: __thiscall ParticleAnchoredSpring::ParticleAnchoredSpring(class Vector3 *,float,float)" (??0ParticleAnchoredSpring@@QAE@PAVVector3@@MM@Z) referenced in function "public: void __thiscall MyGameWorld::Initialize(void)" (?Initialize@MyGameWorld@@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);
};
构造函数声明:
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);
}
答案 0 :(得分:0)
您尚未实现构造函数。你只宣布了它。添加:
ParticleAnchoredSpring::ParticleAnchoredSpring(Vector3 *_anchor, real _springConstant, real _restLength)
: anchor(_anchor), springConstant(_springConstant), restLength(_restLength)
{
}
到您的实施文件。
我假设real
被定义为float
。