我想重载 * 运算符,以便它将类的复杂子变量相乘并返回复杂结果。我的想法如下:
#include <complex>
using namespace std;
class a{
public:
std::complex<double> x0;
...
};
template<class T> complex<T> operator*(const a &lfv, const a &rfv){
return lfv.x0*rfv.x0;
}
但它不起作用......有什么想法或评论吗?