Check out example codes for "tostring in c++". It will help you in understanding the concepts better.

Code Example 1

// to_string example
#include <iostream>   // std::cout
#include <string>     // std::string, std::to_string

int main ()
{
  std::string pi = "pi is " + std::to_string(3.1415926);
  std::string perfect = std::to_string(1+2+4+7+14) + " is a perfect number";
  std::cout << pi << '\n';
  std::cout << perfect << '\n';
  return 0;
}

Code Example 2

// CPP program to illustrate 
// std::to_string 
#include <bits/stdc++.h> 
  
// Driver code 
int main() 
{ 
  
    // Converting float to string 
    std::string str1 = std::to_string(12.10); 
  
    // Converting integer to string 
    std::string str2 = std::to_string(9999); 
  
    // Printing the strings 
    std::cout << str1 << '\n'; 
    std::cout << str2 << '\n'; 
    return 0; 
}

Code Example 3

#include <iostream>

ostream &operator<<(ostream &os, const address &a) {
    os << "{id:" << a.id() << ",name:'" << a.name()
       << ",number:" << a.number() << ",age:" << a.age()
       << "}";
    return os;
}

Learn ReactJs, React Native from akashmittal.com