问下这个问题
smcao 2007-03-17 01:29:43 #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)