C语言改错(指出错误并改正,说明原因)谢谢

来源:百度知道 编辑:UC知道 时间:2024/09/20 02:55:07
#include<iostream.h>
class watch
{
int h,m,s;
public:
watch(int hh,int mm, int ss)
{
h = hh; n=mm;s=ss;
}
void showtime();
}
void showtime()
{
cout<<h<<":"<<m<<":"<<s<<endl;
}
main()
{
watch w1(1,2,3);
w1.showtime();
}

class watch
{
int h,m,s;
public:
watch(int hh,int mm, int ss)
{
h=hh;m=mm;s=ss;//第一处,n=mm改为:m=mm.
}
void showtime();
};//第二处,加上分号,类定义完要加分号.
void watch::showtime()//第三处,方法实现时,要加上类名.
{
cout<<h<<":"<<m<<":"<<s<<endl;
}
void main()//main前加上void,此处不修改有警告.
{
watch w1(1,2,3);
w1.showtime();
}