关于重载的问题?
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace P_ComplexNumber
{
class Program
{
static void Main()
{
ComplexNumber c1 = new ComplexNumber(2, 6);
ComplexNumber c2 = new ComplexNumber(3, -5);
ComplexNumber c3 = c1 + c2;
Console.WriteLine("c3 = {0}", c3);
}
}
public class ComplexNumber
{
public double a = 0, b = 0;
public ComplexNumber(double x1, double x2)
{
a = x1;
b = x2;
}
public static ComplexNumber operator +(ComplexNumber c1, ComplexNumber c2)
{
return new ComplexNumber(c1.a + c2.b, c1.b + c2.b);
}
}
如上源代码,我想实现对加法的重载,但是会出现:
请高手指点!!!