问下这个问题
#include<iostream>
using namespace std;
class student
{
private:
char xh[10],name[20];
float cj;
public:
void cx(char xh)
{int i,j;
for(i=1;i<10;i++)
if( xh==xs[i].xh) // 这里是错在哪里???
{
cout<<"xue sheng xin xi:"<<endl<<"xh name cj "<<endl<<xs[i].xh<<" "<<xs[i].name<<" "<<xs[i].cj<<" ";
break;
}
}
void set()
{
cout<<"shu ru xue sheng qi ben xin xi:\n";
for(i=1;i<10;i++)
{
cout"xh name cj";
cin>>xs[i].xh>>xs[i].name>>xs[i].cj;
}
}
};
class xs[10];
int main()
{
char xhao[10];
set();
cout<<"shu ru ni yao cha xu de xh:\n";
cin>>xh;
cx(xhao);
return 0;
}
错误信息:
--------------------Configuration: Cppfdf1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
D:\zy\C++编程作业\my空间\Cpp1.cpp(14) : error C2065: 'xs' : undeclared identifier
D:\zy\C++编程作业\my空间\Cpp1.cpp(14) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(14) : error C2228: left of '.xh' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2228: left of '.xh' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2228: left of '.name' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2228: left of '.cj' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(24) : error C2065: 'i' : undeclared identifier
D:\zy\C++编程作业\my空间\Cpp1.cpp(26) : error C2143: syntax error : missing ';' before 'string'
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2228: left of '.xh' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2228: left of '.name' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2228: left of '.cj' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(37) : error C2143: syntax error : missing ';' before '['
D:\zy\C++编程作业\my空间\Cpp1.cpp(37) : error C2143: syntax error : missing ';' before '['
D:\zy\C++编程作业\my空间\Cpp1.cpp(43) : error C2065: 'set' : undeclared identifier
D:\zy\C++编程作业\my空间\Cpp1.cpp(46) : error C2065: 'cx' : undeclared identifier
执行 cl.exe 时出错.
Cpp1.obj - 1 error(s), 0 warning(s)
using namespace std;
class student
{
private:
char xh[10],name[20];
float cj;
public:
void cx(char xh)
{int i,j;
for(i=1;i<10;i++)
if( xh==xs[i].xh) // 这里是错在哪里???
{
cout<<"xue sheng xin xi:"<<endl<<"xh name cj "<<endl<<xs[i].xh<<" "<<xs[i].name<<" "<<xs[i].cj<<" ";
break;
}
}
void set()
{
cout<<"shu ru xue sheng qi ben xin xi:\n";
for(i=1;i<10;i++)
{
cout"xh name cj";
cin>>xs[i].xh>>xs[i].name>>xs[i].cj;
}
}
};
class xs[10];
int main()
{
char xhao[10];
set();
cout<<"shu ru ni yao cha xu de xh:\n";
cin>>xh;
cx(xhao);
return 0;
}
错误信息:
--------------------Configuration: Cppfdf1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
D:\zy\C++编程作业\my空间\Cpp1.cpp(14) : error C2065: 'xs' : undeclared identifier
D:\zy\C++编程作业\my空间\Cpp1.cpp(14) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(14) : error C2228: left of '.xh' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2228: left of '.xh' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2228: left of '.name' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(16) : error C2228: left of '.cj' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(24) : error C2065: 'i' : undeclared identifier
D:\zy\C++编程作业\my空间\Cpp1.cpp(26) : error C2143: syntax error : missing ';' before 'string'
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2228: left of '.xh' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2228: left of '.name' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2109: subscript requires array or pointer type
D:\zy\C++编程作业\my空间\Cpp1.cpp(27) : error C2228: left of '.cj' must have class/struct/union type
D:\zy\C++编程作业\my空间\Cpp1.cpp(37) : error C2143: syntax error : missing ';' before '['
D:\zy\C++编程作业\my空间\Cpp1.cpp(37) : error C2143: syntax error : missing ';' before '['
D:\zy\C++编程作业\my空间\Cpp1.cpp(43) : error C2065: 'set' : undeclared identifier
D:\zy\C++编程作业\my空间\Cpp1.cpp(46) : error C2065: 'cx' : undeclared identifier
执行 cl.exe 时出错.
Cpp1.obj - 1 error(s), 0 warning(s)
...全文
相关推荐
小学生计算机辅助教学系统(控制结构程序设计)
1)程序首先随机产生两个1~10之间的正整数,在屏幕上打印出问题,例如: 6*7= 然后让学生输入答案。程序检查学生输入的答案是否正确。若正确,则打印“Right”,然后问下
LabView 简单的串口小程序
在网上找资料,自己写的,比较简单的小程序,呵呵,挺有感觉的,中间遇到过小错误找高手解决了,如果你也遇到问题可以问下我,我也刚学
六年级上册第一单元分数乘法1.4 解决问题练习题及答案【人教版】精选.doc
**五、商场营业额**题目描述:商场上半月营业额480万元,下半月比上半月增加1/4,问下半月的营业额。解答:1. 下半月增加的营业额是上半月的1/4,即480万元 × 1/4 = 120万元。2.
C语言程序实现:有一个整数n,写一个函数f(n),返回0到n之间出现的 "1 "的个数。比如f(13)=6,现在f(1)=1,问下一个最大的f(n)=n的n是什么?
比如f(13)=6,现在f(1)=1,问下一个最大的f(n)=n的n是什么?
citra游戏手柄控制,不完善望修改
因项目需要开发一个通过遥感控制摄像头移动,问下应该如何接收手柄的按键状态呢?,不完善望修改


