No operator << matches these operands

I’ve been reading questions here for an hour or two regarding this error I’m getting and most of them forgot to #include string (which I had already done), or to overload the << operator.

Here’s the code in question:

void Student::getCoursesEnrolled(const vector<Course>& c)
{
    for (int i = 0; i < c.size(); i++)
    {
        cout << c[i] << endl;
    }

}

And the error I’m getting:

Error: No operator matches these operands
    operand types are: std::ostream << const Course

All I’m trying to do is return the vector. I read about overloading the << operator but we haven’t learned any of that in class so I’m assuming there is another way of doing it?

I appreciate your time!

Leave a Comment