operator overloading 1

operator overloading

std::ostream& operator<<(std::ostream& out, const Course& course)
{
    out << course.getName(); // for example
    return out;
}

Here is what the above code is Doing:
1. The first line is the header of the function. It tells the compiler that the function is a friend of the class Course.
2. The second line is the function definition. It tells the compiler that the function is a friend of the class Course.
3. The third line is the function body. It tells the compiler that the function is a friend of the class Course.
4. The fourth line is the return statement. It tells the compiler that the function is a friend of the class Course.
5. The fifth line is the function footer. It tells the compiler that the function is a friend of the class Course.

Similar Posts