📄 11.5.cpp
字号:
#include <iostream.h>
class Date
{
public:
Date(int y,int m,int d)
{
year=y;
month=m;
day=d;
}
friend ostream& operator <<(ostream &stream,Date &date);
friend istream& operator >>(istream &stream,Date &date);
private:
int year,month,day;
};
ostream& operator <<(ostream &stream,Date &date)
{
stream<<date.year<<'/'<<date.month<<'/'<<date.day<<endl;
return stream;
}
istream& operator >>(istream &stream,Date &date)
{
stream>>date.year>>date.month>>date.day;
return stream;
}
void main()
{
Date d(2005,7,11);
cout<<"Current date is "<<d;
cout<<"Enter new date: ";
cin>>d;
cout<<"New date is "<<d;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -