福州芬尼空气能售后:XDJM们帮帮忙好吗??关于C++的!!

来源:百度文库 编辑:高校问答 时间:2024/05/04 23:57:18
帮我看这题哪里出错啦??
#include<iostream.h>
class ChangeTime1 //秒换算为时间
{
int hur,min,sec;
bool good;
public:
ChangeTime1();
void GetTime(int Ts);
int SetTime();
WriteTime(int,int,int);
};
ChangeTime1::WriteTime(int hur,int min,int sec)
{
cout<<"换算后的时间为:";
cout<<hur<<":"<<min<<":"<<sec<<":"<<endl;
}
ChangeTime1::ChangeTime1()
{
hur=0;min=0;sec=0;
}
ChangeTime1::GetTime(int Ts)
{
cout<<"进行换算…………"<<endl;
hur=Ts/3600;
min=(Ts%3600)/60;
sec=(Ts%3600)%60;
WriteTime(hur,min,sec);
}
ChangeTime1::SetTime()
{
int Tsec;
cout<<"Please enter the secone:";
cin>>Tsec;
return Tsec;
}

int main()
{
int Time;
ChangeTime1 Thur;
cout<<"欢迎使用时间换算系统"<<endl;
Time=Thur.SetTime();
Thur.GetTime(Time);
return 0;
}
错误代码为:
D:\Cdocument\program\类定义时间换算.cpp(23) : error C2556: 'int __thiscall ChangeTime1::GetTime(int)' : overloaded function differs only by return type from 'void __thiscall ChangeTime1::GetTime(int)'
D:\Cdocument\program\类定义时间换算.cpp(9) : see declaration of 'GetTime'
D:\Cdocument\program\类定义时间换算.cpp(23) : error C2371: 'GetTime' : redefinition; different basic types
D:\Cdocument\program\类定义时间换算.cpp(9) : see declaration of 'GetTime'
D:\Cdocument\program\类定义时间换算.cpp(44) : error C2264: 'GetTime' : error in function definition or declaration; function not called

秒换算为时间

ChangeTime1();
WriteTime(int,int,int);
都要给各返回类型void 函数结束时要加一个return; 好像c++中没有过程,不能用c语言的过程来写
在函数定义时最前面也要表明函数返回类型,GetTime(int Ts)定义时也要有return;语句作最后返回