📄 test.cpp
字号:
//test.cpp
// test the CDate class
#include <stdio.h>
#include "cdate.h"
void main(void)
{
int days;
CDate tomorrow, temp, //default constructor
today(25, CDate::September, 1997); //initialization constructor
CDate birthday = today; //copy constructor
CDate* datePtr;
tomorrow = today; //assignment
temp = tomorrow++; //post increment
temp = ++birthday; //pre increment
if(birthday == tomorrow) { //eqality operator
// printf("start last minute party plans!\n");
birthday.show(); //display the date
}
birthday.Set(12, CDate::January, 1976);
datePtr = new CDate(31, CDate::December, 1997);
//with compiler optimizations ON the automatic variable 'days'
//will be removed because it is not used after being assigned.
//try disabling 'compiler optimizations that interfere with debugging,'
//in menu EDE : C/C++ Compiler Options : Project Options : Optimization
//and compare the resulting assembly language.
days = datePtr->DayOfYear();
datePtr->show();
(*datePtr)++; //increment to new year
delete datePtr; //kill datePtr
datePtr->Set(1, CDate::October, 1997); //should trap, datePtr is dead
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -