为什么去掉#include"date.h"才能通过啊???可书上明明是这样
//Date.h
class Date //定义日期类
{
public:
void SetDate(int y, int m, int d); //设置日期成员函数
int IsLeapYear(); //判定是否闰年成员函数
void Print(); //输出日期成员函数
private:
int year, month, day; //数据成员
};
//Date.cpp
#include <iostream.h>
void Date::SetDate(int y, int m, int d) //设置日期成员函数
{
year = y;
month = m;
day = d;
}
int Date::IsLeapYear() //判定是否闰年成员函数
{
return(year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
void Date::Print() //输出日期成员函数
{
cout << year << "/" << month << "/" << day << endl;
}
// e7_1.cpp
void main()
{
Date today; //定义日期对象
today.SetDate(2007, 12, 31);
today.Print();
}
这样才能没错