C++ string function return statement -
i'm trying add int string in return statement so:
string birthday::asstring() { return -> day + "/" + -> month + "/" + -> year; }
and getting following error:
error: expression must have integral or unscoped enum type
i'm kind of new c++.
easiest way trying use ostringstream(found in header <sstream>
):
string birthday::asstring() { std::ostringstream out; out << -> day << "/" << -> month << "/" << -> year; return out.str(); }
you getting error show because c++
not know how add integer string.
edit: suggest in m m.'s answer since c++11 there option, namely use function std::to_string.