私はC++を使用したパラメーターのオーバーロードを使用してこれを達成しようとしています:
Complex c(3.0, 4.0);
double magnitude = | c; // magnitude will be 5
私は次のコードを書きました:(ここに必要な部分だけ..)
class Complex
{
public:
double _real;
double _imaginary;
friend double operator|(const Complex &c1)
{
return sqrt(c1._real * c1._real + c1._imaginary * c1._imaginary);
}
}
しかし、次のエラーが発生します。
error C2805: binary 'operator |' has too few parameters
operator |
1つのパラメータだけで使用することは不可能ですか?