#include问题
date.h#include <iostream>
class Date
{
public:
void SetDate(int year,int month,int day);
int IsLeapYear();
void Print();
private:
int year,month,day;
};
void Date::SetDate(int year,int month,int day)
{
this-> year = year;
this-> month = month;
this-> day = day;
}
void Date::Print()
{
printf("%d,%d,%d",this->year,this->month,this->day);
}date.cpp
#include "date.h"
#include <iostream> //为什么还要在使用一次?
int main()
{
Date date;
date.SetDate(2019,10,31);
date.Print();
return 0;
}
date.cpp 中,去掉这一行
#include <iostream> //为什么还要在使用一次?
完全没有问题啊,可以正常编译、运行。
页:
[1]