Ray's playground

 

2011年6月10日

Item 6:Distinguish between prefix and postfix forms of increment and decrement operators.(More Effective C++)

摘要: 1#include<iostream>2usingnamespacestd;34classMyInt5{6private:7inta;8public:9MyInt(intn):a(n){};1011MyInt&operator++()12{13a+=1;14return*this;15};1617constMyIntoperator++(int)18{19MyIntold=*this;20++(*this);2122returnold;23};2425intgetValue()26{27returna;28}29};3031intmain()32{33MyInti(4);3 阅读全文

posted @ 2011-06-10 22:32 Ray Z 阅读(227) 评论(0) 推荐(0) 编辑

导航