帮我看看这个小程序 错误在哪里

fengtao612 fengtao612 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#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;
}

...全文
评论 5
收藏 已收藏
分享
返回顶部
fengtao612
C++ 语言 65,214 成员 250,514 内容