出错二元运算符的参数之一必须是包含类型
看不到运算符重载的错误在哪里
公共静态复杂运算符+错误(复杂 c1,复杂 c2)
namespace testComplex
{
class Program
{
public static Complex operator +(Complex c1, Complex c2)
{
return new Complex(c1.Real + c2.Real, c1.Imaginary + c2.Imaginary);
}
public static Complex operator /(Complex c1, Complex c2)
{
return new Complex(c1.Real / c2.Real, c1.Imaginary / c2.Imaginary);
}
public static Complex operator *(Complex c1, Complex c2)
{
return new Complex(c1.Real * c2.Real, c1.Imaginary * c2.Imaginary + c1.Real * c2.Imaginary + c2.Real * c1.Imaginary);
}
public static Complex operator -(Complex c1, Complex c2)
{
return new Complex(c1.Real - c2.Real, c1.Imaginary - c2.Imaginary);
}
//public static Complex Sqrt -(Complex c1, Complex c2)
//{
//return new Complex(c1.Real - c2.Real, c1.Imaginary - c2.Imaginary);
//}
static void Main(string[] args)
{
Complex a = new Complex(0.5,0);
Complex b = new Complex(0.6,0);
//Complex aa = Math.Exp(-(1 / 4) * a * (b / a + Math.Sqrt(-7 * Math.Pow(b, 2) / Math.Pow(a, 2))) / b + (1 / 4) * b * (a / b + Math.Sqrt(-7 * Math.Pow(a, 2) / Math.Pow(b, 2))) / a);
//Jesus[i] = aa.Real;
Complex aa = Complex.Exp(-(1 / 4) * a * (b / a + Complex.Sqrt(-7 * Complex.Pow(b, 2) / Complex.Pow(a, 2))) / b + (1 / 4) * b * (a / b + Complex.Sqrt(-7 * Complex.Pow(a, 2) / Complex.Pow(b, 2))) / a);
Console.WriteLine(aa.Real);
Console.WriteLine(aa.Imaginary);
Console.ReadKey();
}
}
}