Answers for "how to use tostring method in c++"

C++
0

how to use tostring method in c++

#include <string>

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);
    }
};
Posted by: Guest on July-15-2021

Browse Popular Code Answers by Language