大家看看这个简单的程序是怎么了呀?(高手莫入)

yuanxulong198010 yuanxulong198010 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
下面是我写的一个简单的小程序,但是无法编译通过!
#include <iostream.h>
class mytime
{
public:
int tm_hour;
int tm_min;
int tm_sec;
public:
void get()
{
cout<<tm_hour<<":"<<tm_min<<":"<<tm_sec<<endl;
}
void set(int,int,int);
}
保存为mytime.h文件。
#include "mytime.h"
mytime::set(int h,int m,int s)
{
hour=h;
min=m;
sec=s;
}
保存为mytime.cpp文件。
然后是主文件,如下:
void main() //error:too many type proto>>
{
mytime mtime;
mtime.set(12,35,35);
mtime.get();
} //warning:function should return a value;

为什么不能编译通过呀,是不是我定义的头文件有问题呀,请指教!

...全文
评论 10
收藏 已收藏
分享
返回顶部
yuanxulong198010
C语言 70,039 成员 243,237 内容