袁辉勇 5=16 运算符 重载 ++自增




Date operator ++(int   )

#include <iostream>
using namespace std;
class Date
{
    int y,m,d;
    public:
    Date (int yy,int mm,int dd)
    {  y=yy;m=mm;d=dd;     }
    
    void show()
    {   cout<<y<<'/'<<m<<'/'<<d<<endl; }
    
    Date operator ++(int   )                         
  {  return Date(y,m,d+1);   }    

};


int main()
{
    int y,m,d;
    while(cin>>y>>m>>d)    
 {  Date a(y,m,d),b(2012,5,1);
        b=a++;
        a.show();
        b.show();   
        
}  

  } 











Date operator ++(int n)

Date operator ++(int )


Date operator ++(int n)
this->day++




**************************************************
















C++ 文章被收录于专栏

C++谭浩强 冯博强 贾应知 袁辉勇

全部评论

相关推荐

真烦好烦真烦:豆包润色了自己没看看吗,再说了,都说豆包是愚蠢且勤快的大学生,ds才是聪明的研究生,怎么敢让豆包写论文的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务