📜  如何在 C++ 代码示例中使用 tostring 方法

📅  最后修改于: 2022-03-11 14:44:45.074000             🧑  作者: Mango

代码示例1
#include 

struct Student {
    std::string name;
    int age;
    double finalGrade;

    std::string toString() {
        return "Name: " + 
            name + 
            "\n Age: " + 
            std::to_string(age) + 
            "\n Final Grade: " + 
            std::to_string(finalGrade);
    }
};