第10篇++多态.pptVIP

  • 5
  • 0
  • 约1.08万字
  • 约 75页
  • 2017-06-09 发布于湖北
  • 举报
第10章 多态 本章导读 Complex operator +(Complex c) { Complex temp; temp.Real=Real+c.Real; temp.Image=Image+c.Image; return temp; } Complex operator +(float x) {return Complex(Real+x,Image);} Complex operator +=(Complex c) {Real+=c.Real;Image+=c.Image; return *this; } Complex operator =(Complex c) {Real=c.Real; Image=c.Image; return *this; } bool operator ==(Complex); }; bool Complex::operator ==(Complex c) {return Real==c.RealImage==c.Image);} void main(void) { Complex c1(10,20),c2(100,200); Complex c3,c4; c3=c1+c2;c1.Print();c2.Print(); c3.Print(); c4=c1+5; c4

文档评论(0)

1亿VIP精品文档

相关文档