📄 testdatetime.cpp
字号:
#include "Date.h"
#include "Time.h"
#include "DateTime.h"
#include <stdio.h>
#include <conio.h>
/* test Time and Date's input and output stream.
void main()
{
Time t;
Date d;
DateTime dt1(d,t),dt2("2003,4,2/23:2:3");
cout<<"Input a time: ";
cin>>t;
cout<<t<<endl;
cout<<"Input a date: ";
cin>>d;
cout<<d<<endl;
cout<<dt1<<dt2;
getch();
}
*/
/* test DateTime::Date's constructor.
void main()
{
Date d1(2004,1,3),d2(d1),d3("2005,12,3");
Date d4(2004,13,3),d5(d4),d6("2005,12,52");
cout<<d1<<endl;
cout<<d2<<endl;
cout<<d3<<endl;
cout<<d4<<endl;
cout<<d5<<endl;
cout<<d6<<endl;
getch();
}
*/
/* test Time's constructor.
void main()
{
Time t1(23,2,1),t2(t1),t3("22,1,3");
Time t4(25,1,5),t5(t4);
Time t6("43,32,6");
cout<<t1<<endl;
cout<<t2<<endl;
cout<<t3<<endl;
cout<<t4<<endl;
cout<<t5<<endl;
cout<<t6<<endl;
cin>>t1;
cout<<t1<<endl;
}
*/
/* test DateTime's sub class Date and Time operator.
void main()
{
Date date1(2004,1,3),date2(2001,4,2),date3(2001,4,2);
Time time1(12,3,4),time2(14,3,4),time3(14,3,4);
if( date1==date2 ) { cerr<<"error"<<endl; }
else { cout<<"all right"<<endl; }
if( date2==date3 ) { cerr<<"all right"<<endl; }
else { cout<<"error"<<endl; }
if( time1==time2 ) { cerr<<"error"<<endl; }
else { cout<<"all right"<<endl; }
if( time2==time3 ) { cerr<<"all right"<<endl; }
else { cout<<"error"<<endl; }
if( date2>date3 ) { cerr<<"error"<<endl; }
else { cout<<"all right"<<endl; }
if( date1>date2 ) { cerr<<"all right"<<endl; }
else { cout<<"error"<<endl; }
if( time3>time2 ) { cerr<<"error"<<endl; }
else { cout<<"all right"<<endl; }
if( time2>time1 ) { cerr<<"all right"<<endl; }
else { cout<<"error"<<endl; }
getch();
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -