小编Sam*_*bot的帖子

如何重载+ =运算符来返回一个字符串?

我只是有一个简单的问题:如何重载+ =运算符以返回一个字符串.这是我尝试过的,但没有成功.

// '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)

c++ overloading operator-keyword

0
推荐指数
1
解决办法
1249
查看次数

标签 统计

c++ ×1

operator-keyword ×1

overloading ×1