date1.cpp
来自「C++程序设计源代码例」· C++ 代码 · 共 40 行
CPP
40 行
#include <iostream.h>
class Date
{ int year,month,day;
public:
Date()
{
year=2003; month=1; day=1;
cout<<"Constructor called."<<endl;
}
Date(int y,int m,int d)
{
year=y; month=m; day=d;
cout<<"Constructor called."<<endl;
}
~Date()
{
cout<<"Destructor called."<<endl;
}
void PrintDate()
{
cout<<year<<"-"<<month<<"-"<<day<<endl;
}
};
void main()
{
Date d1,d2(2003,7,12);
cout<<"d1的具体日期为:"<<endl;
d1.PrintDate();
cout<<"d2的具体日期为:"<<endl;
d2.PrintDate();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?