分类:
2008-09-17 11:16:36
#include "stdafx.h"
#include
#include "iostream.h"
#include
class stu
{
public:
char *name;
private:
char *xh;
float cj[3];
float zf()
{
float zf=0;
for(int i=0;i<3;i++)
zf+=cj[i];
return zf;
}
public:
stu(char *nm,char * _xh,float _cj[3]);
void show();
void yhyz();
};
stu::stu(char *nm,char * _xh,float _cj[3])
{
name=nm;
xh=_xh;
for(int i=0;i<3;i++)
cj[i]=_cj[i];
}
void stu::show()
{
cout<
cout<
void stu:: yhyz();
{
char *_xh;
cout<<"学号";
cin>>xh;
if(strcmp(_xh,xh)=0)
cout<<"您已成功登陆";
else
cout<<"错误的用户名或密码";
exit(1);
}
void main()
{ float a[3]={100,100,100};
float b[3]={100,90,95};
float c[3]={90,90,95};
stu zw("zhangwei ","01093232",a);
stu zq("zhangqiang","01093233",b);
stu lk("liuqiang ","01093234",c);
cout<
cout<<"姓名";
loop:
cin>>_name;
if(_name==zw.name)
zw.yhyz();
else
if(_name==zq.name)
zq.yhyz();
else
if(strcmp(_name,lk.name)==0)
lk.yhyz();
else
cout<<"错误的用户名"<
cout<<" 姓名 学号 3人本次年度期末考试的成绩为 :"<
zq.show();
lk.show();
zw.show();
getchar();
}
错误让我无法入睡,跪求大哥大街高手师傅帮忙
E:\学习\实例\projrcts\lei\lei.cpp(53) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
改了可是出现以下错误:该是哪错了呢??
#include "stdafx.h"
#include "stdio.h"
#include "stdafx.h"
#include
#include "iostream.h"
#include
class stu
{
public:
char *name;
private:
char *xh;
float cj[3];
float zf()
{
float zf=0;
for(int i=0;i<3;i++)
zf+=cj[i];
return zf;
}
public:
stu(char *nm,char * _xh,float _cj[3]);
void show();
void yhyz();
};
stu::stu(char *nm,char * _xh,float _cj[3])
{
name=nm;
xh=_xh;
for(int i=0;i<3;i++)
cj[i]=_cj[i];
}
void stu::show()
{
cout<
cout<
void stu:: yhyz()
{
char * _xh;
cout<<"学号:";
gets(_xh);
if(strncmp(_xh,xh,strlen(xh)))
cout<<"您已成功登陆";
else
cout<<"错误的用户名或密码";
}
void main()
{ float a[3]={100,100,100};
float b[3]={100,90,95};
float c[3]={90,90,95};
stu zw("zhangwei ","01093232",a);
stu zq("zhangqiang","01093233",b);
stu lk("liuqiang ","01093234",c);
cout<
cout<<"姓名";
loop:
cin>>_name;
if(strncmp(_name,zw.name,strlen(zw.name))==0)
zw.yhyz();
else
if(strncmp(_name,zq.name,strlen(zq.name))==0)
zq.yhyz();
else
if(strncmp(_name,lk.name,strlen(lk.name))==0)
lk.yhyz();
else
cout<<"错误的用户名"<
cout<<" 姓名 学号 3人本次年度期末考试的成绩为 :"<
zq.show();
lk.show();
zw.show();
getchar();
}
warning C4700: local variable '_xh' used without having been initialized
e:\学习\实例\projrcts\bu hao\bu hao.cpp(84) : warning C4700: local variable '_name' used without having been initialized