Vector multiplication in NRVec


vektor_multipli
10-24-2007, 07:57 AM
Hi everybody,

what I try to do is to implement an operator* into NRVec in such a way, that I can perform an operation like number*vector rather than vector*number which is easy. Any ideas? Thanks a lot,

Holger

Kevin Dolan
10-26-2007, 03:14 AM
You have to implement it as a global function. Something like:

template <class T>
NRVec<T> operator*(const T& x, const NRVec<T>& y);

This one cannot be implemented as a member function, because for the member function version of the operator, the object the operator is a member of is always the left hand argument, and the argument that appears in the function decleration is the right hand argument.


Kevin

vektor_multipli
10-26-2007, 04:32 AM
Thanks Kevin,

I did it that way and it worked.