I've seen all of these 'styles' used for mathematical operations. Could anyone tell me which you prefer, and why?
class Vector3
{
// This?
// Equivalent to a free function.
void normalise();
// Or this?
Vector3& normalise();
// Or this?
Vector3 normalise() const;
}
The first is limiting as you can't use it as part of an equation, but it's unlikely to be confusing. It seems the second and third varieties are more flexible, but could easily be confused, e.g.
// Should v1 be modified here?
Vector3 v1;
Vector3 v2 = v1.normalise();
Which do you use, or which do you prefer? Thanks for any suggestions!