Returning char * instead of string
问题 How may I correct the following code in C++11: const char *what() const noexcept override { return "Mtm matrix error: Dimension mismatch: (" + std::to_string(mat1_height) + "," + std::to_string(mat1_width) + ") (" + std::to_string(mat2_height) + "," + std::to_string(mat2_width) + ")"; } As you can see I'm returning string instead of const char* but won't that be converrted automatically? and how to fix that? Note: I want something to look like c++ code and not c using sprintf for example 回答1: