- 5
- 0
- 约1.02万字
- 约 46页
- 2019-08-10 发布于广东
- 举报
例6.2 (续一) void CComplex::Print() { cout ( real , imag ) endl; } CComplex CComplex::operator +(CComplex c) { CComplex temp; temp.real = real + c.real; temp.imag = imag + c.imag; return temp; } CComplex CComplex::operator -(CComplex c) { CComplex temp; temp.real = real - c.real; temp.imag = imag - c.imag; return temp; } 第6章 多态性 例6.2 (续二) CComplex CComplex::operator *(CComplex c) { CComplex temp; temp.real = real * c.real - imag * c.imag; temp.imag = real * c.imag + imag * c.real; return temp; } void main(void) { CComplex a(1, 2), b(3.0, 4.0), c, d, e, f; c = a+b; d = a-
原创力文档

文档评论(0)