帮我看看这个小程序 错误在哪里
#include<iostream>
#include<stdlib.h>
using namespace std;
class time
{public:
time():h(0),m(0),s(0){};
//~time();
int seth();//设置小时
int setm();//设置分钟
int sets();//
void gettime();
private:
int h;
int m;
int s;
};
int time::seth()
{
cin>>h;
return h;
}
int time::setm()
{
cin>>m;
return m;
}
int time::sets()
{
cin>>s;
return s;
}
void time::gettime()
{cout<<seth()<<":"
<<setm()<<":"
<<sets()<<":";
}
int main()
{
time t;//说这行出了问题
cout<<t.gettime();
t.seth();
t.setm();
t.sets();
cout<<t.gettime();
system("pause");
return 0;
}
题是错误是:41 C:\Documents and Settings\user\桌面\新建文件夹\program\time.cpp expected `;' before 't'
看看这个程序 如果类的名称是a 能够编译通过 可是类名是 time 的话 不能通过
#include<iostream>
#include<stdlib.h>
using namespace std;
class a
{
public:
a(){cout<<"creating a new class";}
};
int main()
{a a1;
system("pause");
return 0;
}