Original Post
Hi all, recently i used bcb for creating static library, and i got some trickies :( and I compile successfully. however, i add the lib into the project, and i always got the error: "[Linker Error] Unresolved external 'XVector::operator +(const XVector&) const' referenced from D:\STUDY\BCB_OP\3DMATH\X3DMATH.OBJ" could anyone know how to solve the issues? thanx a lot
// header file
template <typename T>
class XVector : public Vector<T>
{
public:
XVector();
XVector(float x, float y, float z);
XVector operator+(const XVector&) const;
};
// cpp file
template class XVector<float>;
XVector<float>::XVector()
{
vx = 0.f;
vy = 0.f;
vz = 0.f;
}
XVector<float>::XVector(float x, float y, float z)
{
vx = x;
vy = y;
vz = z;
}
XVector<float> XVector<float>::operator +(const XVector<float> &v) const
{
return XVector<float>(vx + v.vx, vy + v.vy, vz + v.vz);
}
int main(int argc, char* argv[])
{
XVector<float> v1(1.0f, 2.0f, 3.0f), v2(1.f, 2.f, 3.f);
XVector<float> v3;
cout<<v1.vx <<' ' <<v1.vy <<' ' <<v1.vz <<endl;
v3 = v1 + v2;
cout <<v3.vx <<' ' <<v3.vy <<' ' <<v3.vz <<endl;
getchar();
return 0L;
}