missing function header (old-style formal list?)
析构函数和构造函数的头文件是这样的://date.h with copy constructor
#include
using namespace std;
class date
{
public:
date(int y,int m,int d);
date(int y=2000):year(y)
{
month=10;
day=1;
}
date(const date& d);
~date(){cout<<"destructor of date."<
int isleapyear();
void print() {cout
private:
int year,month,day;
};
date::date(int y,int m,int d):year(y),month(m),day(d)
{}
date::date(const date& d)
{
year=d.year;
month=d.month;
day=d.day;
cout
}
int date::isleapyear()
{
return (year%4==0&&year%100!=0)||(year%400==0);
}
调用的主函数是这样的:
#include
#include "date2.h"
using namespace std;
{
date d1(2020,10,3);
date d2(d1);
cout<<"d1:";
d1.print();
cout<<"d2:";
d2.print();
return 0;
}
刚开始学习C++,希望知道问题的兄弟姐妹能指出错误来,小弟感激不尽。谢谢!
没有写入口main,惭愧了。。。