2

我是 C++ 新手,我无法理解为什么会出现此错误。我收到的错误消息是“没有运算符 '<<' 与这些操作数匹配”这是我在发生错误时的编码

#include "LList.h"
#include <iostream>

using namespace std;

int main( )
{
    LList a;

    a.push_back(  "30" );
    a.push_front( "20" );
    a.push_back(  "40" );
    a.push_front( "10" );
    a.push_back(  "50" );

    cout << "list a:\n" << a << '\n';

    return 0;    
}
4

1 回答 1

7

您需要重载operator <<for LList。为此,请执行以下操作:

std::ostream& operator<<(ostream& out, const LList& llist)
于 2013-02-13T19:48:56.930 回答