请问这个c++程序是咋回事,为啥在VC++6.0中不能运行
#include<iostream>#include<string.h>usingnamespacestd;classstudent{private:intnum;str...
#include<iostream>
#include<string.h>
using namespace std;
class student
{
private:
int num;
string name;
int age;
int Cmark;
int mathmark;
public:
student(int xnum=0,string xname="XXX",int xage=0,int xCmark=0,int xmathmark=0)
{
num=xnum;
name=xname;
age=xage;
Cmark=xCmark;
mathmark=xmathmark;
}
~student()
{cout<<"调用析构函数"<<endl;}
void showmark()
{
int zong=Cmark+mathmark;
cout<<zong<<endl;
}
void input(int xx,string mm,int nn,int CC,int ss);
void output();
};
void student::input(int xx,string mm,int nn,int CC,int ss)
{
num=xx;
name=mm;
age=nn;
Cmark=CC;
mathmark=ss;
}
void student::output()
{
cout<<"学号:"<<num<<"姓名:" <<name<<"年龄:"<<age<<"C++:"<<Cmark<<"数学:"<<mathmark<<endl;
}
int main()
{
int number1,age1,scoreC,scoreshu;
string name1;
student xx;
cout<<"请输入学号:"<<endl;
cin>>number1;
cout<<"请输入姓名:"<<endl;
cin>>name1;
cout<<"请输入年龄:"<<endl;
cin>>age1;
cout<<"请输入C++成绩:"<<endl;
cin>>scoreC;
cout<<"请输入高数成绩:"<<endl;
cin>>scoreshu;
xx.input(number1,name1,age1,scoreC,scoreshu);
xx.output();
return 0;
}
Compiling...
1.c
f:\tddownload\vc6.0green\vc98\include\eh.h(32) : fatal error C1189: #error : "eh.h is only for C++!"
执行 cl.exe 时出错.
1.obj - 1 error(s), 0 warning(s) 展开
#include<string.h>
using namespace std;
class student
{
private:
int num;
string name;
int age;
int Cmark;
int mathmark;
public:
student(int xnum=0,string xname="XXX",int xage=0,int xCmark=0,int xmathmark=0)
{
num=xnum;
name=xname;
age=xage;
Cmark=xCmark;
mathmark=xmathmark;
}
~student()
{cout<<"调用析构函数"<<endl;}
void showmark()
{
int zong=Cmark+mathmark;
cout<<zong<<endl;
}
void input(int xx,string mm,int nn,int CC,int ss);
void output();
};
void student::input(int xx,string mm,int nn,int CC,int ss)
{
num=xx;
name=mm;
age=nn;
Cmark=CC;
mathmark=ss;
}
void student::output()
{
cout<<"学号:"<<num<<"姓名:" <<name<<"年龄:"<<age<<"C++:"<<Cmark<<"数学:"<<mathmark<<endl;
}
int main()
{
int number1,age1,scoreC,scoreshu;
string name1;
student xx;
cout<<"请输入学号:"<<endl;
cin>>number1;
cout<<"请输入姓名:"<<endl;
cin>>name1;
cout<<"请输入年龄:"<<endl;
cin>>age1;
cout<<"请输入C++成绩:"<<endl;
cin>>scoreC;
cout<<"请输入高数成绩:"<<endl;
cin>>scoreshu;
xx.input(number1,name1,age1,scoreC,scoreshu);
xx.output();
return 0;
}
Compiling...
1.c
f:\tddownload\vc6.0green\vc98\include\eh.h(32) : fatal error C1189: #error : "eh.h is only for C++!"
执行 cl.exe 时出错.
1.obj - 1 error(s), 0 warning(s) 展开
4个回答
展开全部
#include<string.h> ==> #include<string>
string.h是C中的字符串处理函数,
string中C++中的类,所以你用字符串时出错
string.h是C中的字符串处理函数,
string中C++中的类,所以你用字符串时出错
更多追问追答
追问
不行啊,还是有错误
追答
不会啊,我也直接用VC6.0的环境,是没有问题的,但eh.h这个文件都没有,怎么会提示该文件有问题呢?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
二楼的#include<string.h> 改为 #include<string>正确
如果还有错的话应该是你包含的那个eh.h的问题了,试试删除那个头文件看看会不会报错
如果还有错的话应该是你包含的那个eh.h的问题了,试试删除那个头文件看看会不会报错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询