问下这个问题

smcao smcao 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#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)
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
smcao
C++ 语言 65,214 成员 250,514 内容