Original Post
Hello
I have a few questions about making the best of my vector class implementation. Having an efficient CVector class is surley a big step to making fast-working applications.
1) I use MSVC++ 6.0 and I keep getting some errors when I try to define some operators to be inline - funny thing since for instance ''='' works fine with inline definition but other operators (like ''*'', ''/'') does not. ?? Sure, I can put all the operators inside class definition - the question is : am I 100% guaranteed to have these functions inline expanded?
2) Is there a big difference in these two codes :
*1
3) I can''t spot the difference between :
*A
CVector3 CVector3::operator+ (const CVector3 &Vec)
{
CVector3 result;
result.x = x + Vec.x;
result.y = y + Vec.y;
result.z = z + Vec.z;
return result;
}
*2
CVector3 CVector3::operator+ (const CVector3 &Vec)
{
return CVector3(x + Vec.x, y + Vec.y, z + Vec.z);
}
I guess that there is a pretty big difference since 1* does a lot more (but really?) I am just asking to be sure.
CVector3 CVector3::operator= (const CVector3 &Vec)
{
x = Vec.x;
y = Vec.y;
z = Vec.z;
return *this;
}
*B
CVector3& CVector3::operator= (const CVector3 &Vec)
{
x = Vec.x;
y = Vec.y;
z = Vec.z;
return *this;
}
I mean - I know about this reference in *B but because it doesn''t affect the way of using ''='' I can''t tell the differenece. Now - which one is more likely to be faster?...
Great thanks for all your help/suggestions/blames etc ...
See ya''
----------------------------
... you got me on my knees, Layla