Original Post
I get the following errors in my code, but I can''t understand why:
CBody.obj : error LNK2005: "class CVec3 __cdecl operator+(class CVec3 const &,class CVec3 const &)" (??H@YA?AVCVec3@@ABV0@0@Z) already defined in main.obj
..
..
..
I get one for each operator that''s defined in the class like this:
friend CVec3 operator+ (const CVec3 &v1, const CVec3 &v2);
The whole class (including the operator functions) is defined in a header file, which is included by a couple of things, but at the top of the file I have:
#ifndef CVEC3_H
#define CVEC3_H
So it should only include the code once, so I can''t understand why I''m getting the errors. Directly under the class definition I have the operator functions like this:
CVec3 operator+ (const CVec3 &v1, const CVec3 &v2)
{
return CVec3((v1.m_fVec[0] + v2.m_fVec[0]), (v1.m_fVec[1] + v2.m_fVec[1]), (v1.m_fVec[2] + v2.m_fVec[2]));
}
Any ideas?
---------------------------------------
Let''s struggle for our dream of Game!
http://andrewporritt.4t.com