那位大大帮我看看这个,闹心啊
程序代码://这是一个简单的c++程序,声明一个学生类,其中有名字和学号,也可以对学生的名字学号赋值
#include
#include
using namespace std;
class student
{
public:
char name[20];
int number[10];
public:
void getStudentnu(student * &nu1)
{
nu1 = (student *)malloc(4*sizeof(int));
int i;
cout << "请输入学生的学号: " ;
for(i=0;i<4;i++)
{
cin >> nu1[i]; //错误发生: no match for 'operator>>' (operand types are 'std::istream {aka std::basic_istream<char>}' and 'student')|
}
//当把数组名返回时,实际上是返回了数组的首地址,后续继续使用该地址指向的内存。
} //如果数组为局部变量,那么按照C语言的规则,该段地址在退出函数后,会被释放,并可能被系统做其它用途,
//这样再继续访问该段地址就会引起不可预知错误。所以对于局部数组名是不可以返回的。
//而静态局部变量,开辟的空间不会在退出函数后释放,这时可以返回。
void getStudentna(student * &na1)
{
na1=(student *)malloc(10*sizeof(char));
cout << "请输入学生的姓名: " ;
cin >> na1; //错误发生: no match for 'operator>>' (operand types are 'std::istream {aka std::basic_istream<char>}' and 'student*')|
}
void printStudent(student * &s)
{
int i;
cout << "学号是: " << endl;
for(i=0;i<4;i++)
{
cout << s->number[i];
}
cout << " " << endl;
cout << "姓名是: " << s->name << endl;
}
};
int main()
{
student *st;
cout << "请输入学生的具体信息: " << endl;
st->getStudentna(st->number);
st->getStudentnu(st->name); //错误发生:no matching function for call to 'student::getStudentnu(char [20])'|
st->printStudent(st);
system("pause");
return 0;
}









