perlperl
asked on
stringstream
What is the use of stringstream to return string in this format. I see at most places in my application
I am not sure why didn't the original developer wrote something like this.
Is there any specific benefit of method 1 over method 2 except saving 1 line ?
std::string SID::to_string() const
{
std::stringstream short_sid_stream;
short_sid_stream << _in << "-" << _out;
return short_sid_stream.str();
}
I am not sure why didn't the original developer wrote something like this.
std::string SID::to_string() const
{
std::string short_sid (_in);
short_sid += "-";
short_sid += _out;
return short_sid();
}
Is there any specific benefit of method 1 over method 2 except saving 1 line ?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.