这个c++的类不知道怎么定义,运行时总是说类没定义,下面是源码
#ifndef TIME_H#define TIME_H
class Time
{
public:
Time();
Time(int elapsetime);
int getElapseTime();
void setElapseTime(int elapsetime);
int getHour();
int getMinute();
int getSecond();
int setTime(int elapsetime);
private:
int elapseTime;
};
#endif
#include "Time.h"
#include <cmath>
using namespace std;
Time::Time()
{
elapseTime=555550;
}
Time::Time(int elapsetime)
{
elapseTime=elapsetime;
}
int Time::getElapseTime()
{
return elapseTime;
}
void Time::setElapseTime(int elapsetime)
{
elapseTime=elapsetime;
}
int Time::getHour()
{
int hour=elapseTime/3600;
return hour;
}
int Time::getMinute()
{
int minute=elapseTime%3600/60;
return minute;
}
int Time::getSecond()
{
int second=elapseTime%3600%60;
return second;
}
#include<iostream>
#include<iomanip>
#include"Time.h"
using namespace std;
int main()
{
cout<<"Enter elapseTime:";
int elapseTime;
cin>> elapseTime;
Time :: Time(elapseTime);
cout<<"The hour is:"<<Time.getHour()<<endl;
cout<<"The minute is:"<<Time.getMinute()<<endl;
cout<<"The second is:"<<Time.getSecond()<<endl;
}