⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 日期类的自增和自减运算符的重载3问题.txt

📁 学C++的同学是不是遇到麻烦了
💻 TXT
字号:
#include  <iostream.h>
class    Date
{
   public: 
	   Date(){}
	   Date(int  y,int  m,int  d){year=y;  month=m;  day=d;}	 
       void   Print() {cout<<year<<","<<month<<","<<day<<endl;}
	   Date   operator ++(int);
	   Date   operator --(int);
    private:
         int   year ,  month,  day;
};
Date  Date::operator ++(int)
{
	day++;
	return  *this;
}
Date  Date::operator --(int)
{
	day--;
	return  *this;
}

void  main()
{
   Date  today(2003,10,13),tomorrow,yesterday;
   cout<<"Today  is  ";
   today.Print();

   cout<<"Tomorrow  is   ";
   today++;
   tomorrow=today;
   tomorrow.Print();

   cout<<"Yesterday  is  ";
   tomorrow--;
   today=tomorrow;
   today--;
   yesterday=today;
   yesterday.Print();

     int   i=10;
     i--;
     cout<<i<<endl;
     编译通得过否?
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -