I have a class cnVector that represents a point in 3 dimensional space.
Its operators + – * / are used intensively.
Their implementation is very short:
cnVector cnVector::operator + (const cnVector& v) const {
return cnVector(
x + v.x,
y + v.y,
z + v.z );
}
My question is, because this function is very short, should I inline it although its intensive use? or would it generate too much code when using it that much?
Yes you probably should. The good use case for the inline keyword in c++ is: small functions, heavily used.
See also http://msdn.microsoft.com/en-us/library/1w2887zk%28v=vs.80%29.aspx