Suppose this is my class:
class Student {
std::string name;
int CWID;
public:
Student(std::string name = "N/A", int CWID = 99999999) : this->name(name), this->CWID(CWID) {}
};
Now, how do I overload the output stream operator <<
that will print all the data in the class. I'm guessing this is equivalent to the toString()
method in Java but kindly show me how to do it in C++.