大家来帮忙啊
大家来帮忙啊
楼主yth0825(Crane)2004-02-28 15:35:01 在 C/C++ / C++ 语言 提问 为什么我编的程序运行不了啊 程序如下#include <iostream.h>
#include <iomanip.h>
class Date
{
private:
int month;
int day;
int year;
public:
Date(int = 7,int = 4,int = 2001);
void setdate(int, int, int);
void showdate();
}
Date::Date(int mm, int dd, int yyyy)
{
month = mm;
day = dd;
year = yyyy;
}
void Date::setdate(int mm, int dd, int yyyy)
{
month = mm;
day = dd;
year = yyyy;
return;
}
void Date::showdate()
{
cout << "The date is";
cout << setfill ("0")
<< setw(2) << month << "/"
<< setw(2) << day << "/"
<< setw(2) << year % 100;
cout << endl;
return;
}
int main()
{
Date a, b, c(4,1,1998);
b.setdate(12,25,2002);
a.showdate();
b.showdate();
c.showdate();
return 0;
}
编译之后提示如下:c:\haha\haha.cpp(15) : error C2533: "Date::Date" : constructors not allowed a return type
c:\haha\haha.cpp(40) : error C2264: "Date::Date" : error in function definition or declaration; function not called
c:\haha\haha.cpp(40) : error C2264: "Date::Date" : error in function definition or declaration; function not called
c:\haha\haha.cpp(40) : error C2264: "Date::Date" : error in function definition or declaration; function not called
Error executing cl.exe.
haha.exe - 4 error(s), 0 warning(s)
快解救我一下吧
问题点数:20、回复次数:4Top
-
相关文章
2秒记住本站域名
玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的readygo.com.cn
