变量在结构体定义后,赋值是出现异常:表达式必须是可修改的左值
变量在结构体定义后,赋值是出现错误:表达式必须是可修改的左值
//DataType数据元素的数据类型
typedef string DataType;
typedef struct examinee
{ DataType examno[10]; //准考证号
DataType name[10]; //姓名
DataType sex;
float age;
DataType examtype[5]; //成绩
Node *next;
} Node;
int ListInsert (Node *H , DataType exno,DataType n,DataType sex,float age,DataType score)
{
Node *p=H; int i=0;
if(p==NULL){ //查找不成功,退出运行
cout<<"插入位置无效"<<endl;
return 0;
}
while(p)
p=p->next;
if(p->next == NULL){
Node *t=new Node;
t->examno=exno; //表达式必须是可修改的左值
t->name=n;
我这变量哪里有问题了?要怎么改?
------解决方案--------------------
t->examno=exno
左边是string数组,右边只是string变量而已!
你需要的目的是什么?
------解决方案--------------------
数组不可以直接赋值,况且你是想让 string[] = string,目的何在?
------解决方案--------------------
DataType examno[10];
examno是数组啊。。。。。
------解决方案--------------------
你为啥要用一列字符串对象来存储一个准考证号/姓名/成绩?你这是什么设计?
//DataType数据元素的数据类型
typedef string DataType;
typedef struct examinee
{ DataType examno[10]; //准考证号
DataType name[10]; //姓名
DataType sex;
float age;
DataType examtype[5]; //成绩
Node *next;
} Node;
int ListInsert (Node *H , DataType exno,DataType n,DataType sex,float age,DataType score)
{
Node *p=H; int i=0;
if(p==NULL){ //查找不成功,退出运行
cout<<"插入位置无效"<<endl;
return 0;
}
while(p)
p=p->next;
if(p->next == NULL){
Node *t=new Node;
t->examno=exno; //表达式必须是可修改的左值
t->name=n;
我这变量哪里有问题了?要怎么改?
------解决方案--------------------
t->examno=exno
左边是string数组,右边只是string变量而已!
你需要的目的是什么?
------解决方案--------------------
数组不可以直接赋值,况且你是想让 string[] = string,目的何在?
------解决方案--------------------
DataType examno[10];
examno是数组啊。。。。。
------解决方案--------------------
你为啥要用一列字符串对象来存储一个准考证号/姓名/成绩?你这是什么设计?