编译中出现的错误,大家帮忙看看,谢谢

napoleonpan napoleonpan 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
//如果是闰年,打印年月日
#include <iostream>
#include <iomanip>
using namespace std;

class Date
{
private:
int year, month, day;
public:
void set(int y, int m, int d);
bool isLeapYear() const;
void print() const;
};

inline void Date::set(int y, int m, int d)
{
year=y, month=m, day=d;
}

inline bool Date::isLeapYear()
{
return ( (year%4==0 && year%100!=0) || year%400==0 );
}

inline void Date::print()
{
cout << setfill('0');
cout << setw(4) << year << "-"
<< setw(2) << month << "-"
<< setw(2) << day << endl;
}

int main()
{
Date *dp = new Date;
dp->set(2000,12,12);
if( dp->isLeapYear())
dp->print();
else
cout << "not a LeapYear.";
return 0;
}

错误信息://怎么会有重载的错?真不明白。
C:\临时\f08032.cpp(21) : error C2511: 'isLeapYear' : overloaded member function 'bool (void)' not found in 'Date'
C:\临时\f08032.cpp(6) : see declaration of 'Date'
C:\临时\f08032.cpp(26) : error C2511: 'print' : overloaded member function 'void (void)' not found in 'Date'
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
napoleonpan
C++ 语言 65,214 成员 250,514 内容