我只是有一个简单的问题:如何重载+ =运算符以返回一个字符串.这是我尝试过的,但没有成功.
// 'Student' is the class that this function is in
// 'get_name()' returns the name of the student
// 'get_grade()' returns the grade of the student
// Description:
// Ultimately I will be creating a list of students and their grades in
// the format of (Student1, Grade1) (Student2, Name2) ... (StudentN, GradeN)
// in a higher level class, and thus I need an overloaded += function.
Student& Student::operator+=(const Student& RHS)
{
string temp_string;
temp_string = "( " …Run Code Online (Sandbox Code Playgroud)