How to display a list in c++

时间:2017-11-02 15:39:17

标签: c++ list

I am trying to print a list in C++.
My code is as follows:

void MovieFunctions::printMovieList(list<Movie> movies)
{
    for (Movie m: movies)
    {
        cout << m << endl;
    }
}

I am getting this error for the cout << m << endl line:

cannot convert 'm' (type 'Movie') to type 'const unsigned char*'

What's going wrong?

1 个答案:

答案 0 :(得分:6)

You need to implement the operator<<() (here) for this purpose.