标签:blog io ar os sp on 2014 log cti
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Sample_01_CA { public class Complex { //定义复试的实部和虚部 private int integer; private int fraction; //构造函数 public Complex(int integer,int fraction) { this.integer = integer; this.fraction = fraction; } //重载运算符 public static Complex operator +(Complex left,Complex right) { return new Complex(left.integer + right.integer, left.fraction + right.fraction); } //重写从Object继承的ToString()方法 public override string ToString() { return integer.ToString()+"."+fraction.ToString(); } static void Main(string[] args) { Complex left = new Complex(2008, 10); Complex right = new Complex(100, 1); Console.WriteLine(left.ToString() + " + " + right.ToString() + " = " + (left + right).ToString()); Console.Read(); } }; }
标签:blog io ar os sp on 2014 log cti
原文地址:http://blog.csdn.net/qsyzb/article/details/41821731