Search
 
SCRIPT & CODE EXAMPLE
 

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);
    }
};
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ do every 1 minutes 
Cpp :: c pre-processor instructions 
Cpp :: Find the biggest element in the array 
Cpp :: priority queue in c++ 
Cpp :: best websites for programming 
Cpp :: how many months have 31 days 
Cpp :: how to change colour image to grey in opencv c++ 
Cpp :: sort vector from largest to smallest 
Cpp :: c plus plus 
Cpp :: how to use custom array in c++ 
Cpp :: length of number c++ 
Cpp :: vector library c++ 
Cpp :: how to remove first element from vector c++ 
Cpp :: c++ access second last element of vector 
Cpp :: function overriding in c++ 
Cpp :: c++ random number 
Cpp :: double array size c++ 
Cpp :: cpp get exception type 
Cpp :: prime number c++ 
Cpp :: oop in cpp 
Cpp :: rock paper scissor c++ 
Cpp :: google test assert stdout 
Cpp :: how to check if vector is ordered c++ 
Cpp :: Initialize Vector Iterator Through Vector Using Iterators 
Cpp :: c++ hash map key count 
Cpp :: cout stack in c++ 
Cpp :: files in c++ 
Cpp :: find first of a grammar 
Cpp :: shift element to end of vector c++ 
Cpp :: definition of singly linkedlist 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =