【发布时间】:2016-01-10 21:50:27
【问题描述】:
Node* Insert(Node *head,int data)
{
Node *current=head;
Node *new=(Node *)malloc(size0f(Node));
new->data=data;
while(current->next!=NULL)
{
current=current->next;
}
current->next=new;
new->next=NULL;
return head;
}
错误:
solution.cc: In function 'Node* Insert(Node*, int)':
solution.cc:23:10: error: expected unqualified-id before 'new' Node *new=(Node *)malloc(size0f(Node)); ^
solution.cc:23:10: error: expected initializer before 'new'
solution.cc:24:7: error: expected type-specifier before '->' token new->data=data; ^
solution.cc:29:22: error: expected type-specifier before ';' token current->next=new; ^
solution.cc:30:8: error: expected type-specifier before '->' token new->next=NULL;
【问题讨论】:
-
solution.cc: In function 'Node* Insert(Node*, int)': solution.cc:23:10: error: expected unqualified-id before 'new' Node *new=(Node *)malloc(size0f(节点)); ^ solution.cc:23:10: 错误:'new' solution.cc:24:7 之前的预期初始化程序:错误:'->' token new->data=data 之前的预期类型说明符; ^ solution.cc:29:22: 错误: ';' 之前的预期类型说明符令牌当前->下一个=新; ^ solution.cc:30:8: error: '->' token new->next=NULL 之前的预期类型说明符; ^
标签: data-structures