I have a container class. I would like to left and right multiply this class by both literal values and other classes. That is, I would like to do something like what follows.
template <class T>
class myClass {
myClass();
template <class U> const myClass<T> operator *( const U &value ) const;
template <class U> friend const myClass <U> operator *( const U &value, const myClass <U> &in );
template <class S> const myClass<T> operator *( const myClass<S> &in ) const;
};
When I do that though, I get an error when I try to do something like 'myClass<double> = 8 * classInstance'. The error statment is as follow:
Quote:
template parameter U is ambiguous
I suspect that it is ambiguous because U can be an element of type myClass.
Is there some way to do this? Where left and right multiplication by an object of type myClass is one set of functions, and left and right multiplication of everything else is a different set of functions?
As always, thank you all for your help.