小编wig*_*ily的帖子

C++:链接列表和指针乐趣

关于指针的使用有一点我在这里不明白Cell *curr = head;它的地址head和它有什么作用?

Cell *ConvertToListIter(Vector<int>& vector)
{
    Cell *head = new Cell;
    head->next = NULL;
    head->value = vector[0];
    Cell *curr = head;

    for (int i = 1; i < vector.size(); i++) {
        Cell *newCell = new Cell;
        newCell->next = NULL;
        newCell->value = vector[i];
        curr->next = newCell;
        newCell = curr;
    }

    return head;
}
Run Code Online (Sandbox Code Playgroud)

c++ pointers linked-list

2
推荐指数
1
解决办法
164
查看次数

标签 统计

c++ ×1

linked-list ×1

pointers ×1