C++ 暑期实践课程第08讲.ppt.pptVIP

  • 5
  • 0
  • 约8.22千字
  • 约 39页
  • 2016-09-29 发布于江西
  • 举报
C++ 暑期实践课程第08讲.ppt.ppt

* Tsinghua University, lily * * 值返回与引用返回 运算符重载的返回值一般都是类的对象,但为何有的是值返回,有的是引用返回。 如果返回的是一个临时对象,就必须采用值返回,而不能采用引用返回。 如果返回值希望再作为左值,就应该采用引用返回,而不是值返回。 * Tsinghua University, lily * * #includeiostream using namespace std; class RMB { public: RMB(unsigned int d,unsigned int c); RMB operator +(RMB); RMB operator ++(); RMB operator ++(int); void display(); friend ostream operator (ostream os,const RMB r); private: unsigned int yuan; unsigned int jf; }; * Tsinghua University, lily * * RMB::RMB(unsigned int d,unsigned int c) { yuan = d;jf = c; while (jf=100) { yuan++;jf-=100;}} RMB

文档评论(0)

1亿VIP精品文档

相关文档