111,126
社区成员
发帖
与我相关
我的任务
分享
using System;
namespace ConsoleApplication1
{
public class ComplexType
{
public double r1;
public double r2;
public ComplexType(double R1, double R2)
{
r1 = R1;
r2 = R2;
}
public static ComplexType operator ++(ComplexType test)
{
test.r1++;
test.r2++;
return test;
}
}
class Program
{
static void Main(string[] args)
{
ComplexType test = new ComplexType(2, 3);
(++test)++;//这句抛出了一个异常
Console.WriteLine("R1 = {0}\n" + "R2 = {1}", test.r1, test.r2);
}
}
}