小编mcu*_*001的帖子

链接列表输出崩溃

输出链接列表的内容时,我的程序挂起.我无法更改标头,只能更改cpp文件.

playlist.h:

class PlayList {
    private:

    struct SongNode {
        Song data;
        SongNode* next;
        SongNode (const Song& s, SongNode* nxt = 0)
          : data(s), next(nxt)
        {}
    };

    friend std::ostream& operator<< (std::ostream& out, const PlayList& s);

    SongNode* first; // head of a list of songs, ordered by title, then artist
    //Snip...

    inline
    std::ostream& operator<< (std::ostream& out, const PlayList& pl)
    {
        for (PlayList::SongNode* current = pl.first; current != 0; current = current->next)
            out << current->data << std::endl;
        return out;
    }
Run Code Online (Sandbox Code Playgroud)

playlist.cpp

using namespace …
Run Code Online (Sandbox Code Playgroud)

c++ linked-list

4
推荐指数
1
解决办法
284
查看次数

标签 统计

c++ ×1

linked-list ×1