defining new operator

Hi, i'm trying to define a new operator ** but the compiler g++ gives error:
expected initializer before ‘*’ token.


I use the following code :

1
2
3
4
5
6
template <class T>
inline Matrix<T> operator**(const Matrix<T>& x, const Matrix<T>& y){
	Matrix<T> tmp(x);
	tmp.TensorProd(y);
	return tmp;
}


Anyone knows what the problem is ?

Thx



You can't define new operators. You can only implement existing ones.

Don't get cute with operator overloading. The reason it exists is to make code more natural. It's not there to save you from typing out function names.

If you find that you're being "clever" with operator overloading, you're probably doing it wrong. They're not meant to be clever, they're meant to be intuitive.
Topic archived. No new replies allowed.