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.


Popular posts from this blog

Php - Delimiter must not be alphanumeric or backslash -

c# - How to change the "Applies To" field under folder auditing options programatically (.NET) -

c++ - Ambiguity when using boost::assign::list_of to construct a std::vector -