我想让函数返回特定节点的地址.但是编译器没有检测到我创建的节点数据类型结构.
struct node
{
int data;
node *link;
};
node *header,*current;
node traverse(int pos);
node *Linkedlist::traverse(int pos)
{
int location = 0;
current->link = header->link;
node *address = new node;
address->data = NULL;
address->link = NULL;
while(current->link != NULL)
{
if(location == pos)
{
cout <<current->link->data <<" "<< endl;
address->link=current->link;
}
location ++;
current->link = current->link->link;
}
return address->link;
}
Run Code Online (Sandbox Code Playgroud)
更改
return *address;
Run Code Online (Sandbox Code Playgroud)
至
return address;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6522 次 |
最近记录: |