Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to use tostring method in c++

#include <string>

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

    std::string toString() {
        return "Name: " + 
            name + 
            "
 Age: " + 
            std::to_string(age) + 
            "
 Final Grade: " + 
            std::to_string(finalGrade);
    }
};
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #tostring #method
ADD COMMENT
Topic
Name
1+2 =