The class gets bigger because of a pointer to the vtable.
ok this is exactly what i wanted to hear, even if it doesnt solve my problem.
That said, there shouldn't be any reason that a vector class should have any virtual functions in it. Inheriting from a 3D vector is a somewhat bizarre option.
Virtual is for inheritance purposes - your class isn't inheriting, and likely shouldn't be inherited from, so none of the functions should be virtual.
yeah i know, and i don't want to do that. i usually only use virtual functions to create 'interface classes' which have several context specific implementations, and the one used gets decided at runtime. this at least is what i've been using virtual for, to exploit polymorphism
the way i used them here, to be honest, i just discovered by mistake that they worked, i have no idea as to why one would need the 'virtual', and what it does. like i said, the linker bugs me if i don't, if i do, everything works 100% as expected, except the vtable pointer gets added (which i cant have due to memory alignment issues). even more important, i want to know why the one version with virtual works, while the other raises linker errors, even though there's no inheriting going on whatsoever, since this code is being written for educational purposes.
What does your function declaration look like? Your linker errors may be related to that. Could you post the error message?
hm... this is the declaration. are you maybe referring to the definition?
inline Vector3 Vector3::operator=(const Vector3 &v)
{
Vector3 ret;
ret.x = x = v.x;
ret.y = y = v.y;
ret.z = z = v.z;
return ret;
}
the linker error i get when NOT using virtual:
error LNK2001: Uresolved external Symbol ""public: class Vector3 __thiscall Vector3::operator=(class Vector3 const &)" (??4Vector3@@QAE?AV0@ABV0@@Z)".
ok, thanks sofar for all those answers, im sort of a newb here, and really appreciate this. also thanks for not posting workarounds or alternatives, since that wont help me (read the bold text again to find out why =) ).
needless to say, i got more ops overloaded, which aren't assignments they suffer the same dilemma
thanks again, can't wait to get on this again
cheers,
tasche