编译中出现的错误,大家帮忙看看,谢谢
//如果是闰年,打印年月日
#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'
#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'
...全文
相关推荐
c++常见20个编译错误
"C++常见20个编译错误"C++是一种功能强大且灵活的编程语言,但是在编译过程中经常会出现一些错误,以下是20个常见的C++编译错误:1、fatal error C1010: unexpected end
常见ARM编译错误
解决ARM编译错误的关键在于理解错误信息、仔细检查代码和配置,以及熟悉编译工具的使用。通过以上步骤和对编译过程的理解,大多数常见错误都能被有效解决。
Microsoft VBScript 编译器错误 错误原因 代码大全
通过仔细阅读错误消息和调试代码,通常可以定位并解决VBScript编译器错误。
KEIL 常见编译错误大全
在使用KEIL进行嵌入式软件开发的过程中,遇到编译错误是常见现象。KEIL软件开发环境中的编译器设计得非常强大,可以处理各种常见的编程错误。然而,即使是经验丰富的开发者,有时也会遇到编译错误。
常见的vc编译错误
### 常见的VC编译错误解析在VC++编程过程中,遇到各种编译错误是在所难免的,尤其对于初学者而言,了解并掌握如何处理这些错误是至关重要的。下面将详细介绍文中提及的一些常见编译错误及其解决方法。


