I tried to make the code #1 more terse by changing it to code #2 but it doesn't work as expected. Can anyone please tell me why it doesn't work? Thanks.
Code #1
double x = 8.9, y = 3.4, z = -4.5;
std::ostringstream q0;
q0 << "(" << x << "," << y << "," << z << ")";
std::string s = q0.str();
Code #2
double x = 8.9, y = 3.4, z = -4.5;
std::string s = static_cast<std::ostringstream &>(
std::ostringstream() << "(" << x << "," << y << "," << z << ")").str();