首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

简单的编绎出错。该如何解决

2012-03-16 
简单的编绎出错。#include iostream.h//入门时钟的程序classclock{private:intM,S,Hpublic:voidsettime(

简单的编绎出错。
#include <iostream.h>                   //入门时钟的程序            
class   clock
{
private:
int   M,S,H;
public:
void   settime(int   Nh=0,int   Nm=0,int   Ns=0)
{
{M=Nm;
H=Nh;
S=Ns;
}
        void   showtime()
{cout < <H < < ": " < <M < < ": " < <S;
}
};
void   main()
{
clock   mC;
mC.settime();
mC.showtime();
cout < <endl;
        mC.settime(3,1,6);
mC.showtime();
}
---------
提示
fatal   error   C1004:   unexpected   end   of   file   found
那么哪里错了?
还有,我经常编绎一些C++时,VC6就会“死“了,compile那栏就会反白,stop   compile也没反应,这是为什么呢?


[解决办法]
mC.settime();
//这个匹配参数呢?
[解决办法]
void settime(int Nh=0,int Nm=0,int Ns=0)
{
{M=Nm;

//{号多了个
[解决办法]
函数内嵌函数、双字节分号、大括号差一个,缩进不合理
问题很严重
其它问题估计是你系统的问题
[解决办法]
#include <iostream>
using namespace std;
class clock
{
private:
int M,S,H;
public:
void settime(int Nh=0,int Nm=0,int Ns=0)
{
M=Nm;
H=Nh;
S=Ns;
}
void showtime()
{
cout < <H < < ": " < <M < < ": " < <S;
}
};
int main()
{
clock mC;
mC.settime();
mC.showtime();
cout < <endl;
mC.settime(3,1,6);
mC.showtime();
return 0;
}
[解决办法]
上面的程序OK了..
LZ啊,以后写程序要注意括号的匹配问题哦...
[解决办法]
一共3个错误;
#include <iostream.h> //1.这里改成 #include <iostream> using namespace std;


class clock
{
private:
int M,S,H;
public:
void settime(int Nh=0,int Nm=0,int Ns=0)
{
{M=Nm; // 2.这里多了个括号
H=Nh;
S=Ns;
}
void showtime()
{cout < <H < < ": " < <M < < ": " < <S;
}
}; //3.你的这里的分号错了,应该是在英文状态下的...要小心
void main()
{
clock mC;
mC.settime();
mC.showtime();
cout < <endl;
mC.settime(3,1,6);
mC.showtime();
}
[解决办法]
改了以后的程序:
#include <iostream>
using namespace std;

//入门时钟的程序
class clock
{
private:
int M,S,H;
public:
void settime(int Nh=0,int Nm=0,int Ns=0)
{
M=Nm;
H=Nh;
S=Ns;
}
void showtime()
{
cout < <H < < ": " < <M < < ": " < <S;
}
};

void main()
{
clock mC;
mC.settime();
mC.showtime();
cout < <endl;
mC.settime(3,1,6);
mC.showtime();
}

OK了

热点排行