0

The following code is a minimal example of what I am trying to do. When I compiled it with

Visual C++ 2008 Express, I got the error:

main.cpp(62) : error C2677: binary '*' : no global operator found which takes type 'Point<T>' (or there is no acceptable conversion)

1> with

1> [

1> T=float

1> ]

1> main.cpp(68) : see reference to function template instantiation 'void foo<float,double>(T,T,T)' being compiled

1> with

1> [

1> T=float

1> ]

**However**, if I change foo so that it does not take any parameter, the error will be gone.

Could anyone tell me where I am wrong? Thanks

```
template<class T>
class Point {
private:
T x, y, z;
public:
Point(T xx, T yy, T zz) : x(xx), y(yy), z(zz) {}
template<class U> operator Point<U> () const { return Point<U>( U(x), U(y), U(z) ); }
};
template<class T>
class Matrix{
private:
T m[16];
public:
Matrix(T x, T y, T z){}
Point<T> operator* (const Point<T>& p) { return Point<T>(0,0,0); }
};
/* this does not work */
template<class T, class C>
void foo(T x, T y, T z)
{
Point<T> o1(0,0,0);
Matrix<C> m(C(x),C(y), C(z));
m * o1;
}
/*but this does work
template<class T, class C>
void foo()
{
Point<T> o1(0,0,0);
Matrix<C> m(C(1),C(1), C(1));
m * o1;
}
*/
int main()
{
foo<float,double>(1,1,1); // failed
// foo<float,double>(); works
return 0;
}
```