chap6_运算符重载.pptVIP

  • 2
  • 0
  • 约1.17万字
  • 约 25页
  • 2016-11-28 发布于河南
  • 举报
chap6_运算符重载

问题引出:自定义类型的运算 #include iostream.h class CComplex { public: CComplex(double rt=0,double it=0) ; void disp(); void set(double,double); void get(double,double); CComplex add(CComplex ); CComplex dec(CComplex ); private: double r,i; }; CComplex::CComplex(double rt,double it) { r=rt;i=it; } void CComplex::set(double rt,double it) { r=rt;i=it; } void CComplex::get(double rt,double it) { rt=r;it=i; } void CComplex::disp() { if (r||r==0i==0) coutr; if (i0r) cout +; if (i) { if (i==1) ; else if (i==-1) cout-; else couti; couti; } coutendl; } CComplex CComplex::add(CComplex

文档评论(0)

1亿VIP精品文档

相关文档