正在加载图片...
第8章多态性 例8.1(续二) void main(void) CComplex a(1,2),b(3.0,4.0),c,d; c= atb d= a-b: Cout <s uc= 该语句相当于对函数。 perator+( CComplex c) C Printo 的调用:“c= a operator+(b)”,实现两个复数 的加法运算 cout < " d=" d Printo 程序运行结果为 c=(4,6) d=(-2,-2)例8.1 (续二) void main(void) { CComplex a(1, 2), b(3.0, 4.0), c,d; c = a+b; d = a-b; cout << "c = "; c.Print(); cout << "d = "; d.Print(); } 第8章 多态性 该语句相当于对函数operator +(CComplex c) 的调用:“c=a.operator +(b)”,实现两个复数 的加法运算。 程序运行结果为: c = (4, 6) d = (-2, -2)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有