表达式必须为可修改的左值。

typedef int MHF;

typedef struct LNode

{

char quming[20];

char zuozhe[20];

char geshou[20];

MHF nian;

MHF yue;

MHF ri;

struct LNode *next;

}LNode, *LinkList;

int listinsert(LinkList &L, int i, char *quming, char *zuozhe, char *geshou, MHF &nian, MHF &yue, MHF &ri)

{

if (i < 1) return 0;

int j = 0;

LinkList p = L,s;

while ((j < i - 1) && p != NULL)

{

p = p->next;

j++;

}

if (p == NULL)

return 0;

else

{

s = new LNode;

if (s == NULL)

{

cout << "结点分配失败\n";

return 0;

}

s->quming = quming;

cout << quming << endl;

cout << s->quming << endl;

s->geshou = geshou;

cout << geshou << endl;

cout << s->geshou << endl;

s->zuozhe = zuozhe;

cout << zuozhe << endl;

cout << s->zuozhe << endl;

s->nian = nian;

s->yue = yue;

s->ri = ri;

s->next = p->next;

p->next = s;

return 1;

}

}

s报错,说表达式必须为可修改的左值,这是为什么???

Ma峰
浏览 8057回答 2
2回答

望远

就是说你表达式里面的左边的必须是变量,不能是常量 eg:int n=2;//赋值表达式n=2的左值为变量n,合法     2=2非法
打开App,查看更多内容
随时随地看视频慕课网APP