1 #include <iostream> 2 #include<string> 3 4 namespace str_utils { 5 6 std::string to_string(const char* c_str) { 7 std::cout << "调用了 cstr" << std::endl; 8 return std::string(c_str); 9 } 10 11 template<class canToString> 12 std::string to_string(canToString value) { 13 std::cout << "调用了其他" << std::endl; 14 return std::to_string(value); 15 } 16 } 17 int main() 18 { 19 auto sSum = str_utils::to_string(200.3003)+str_utils::to_string("2222"); 20 std::cout << sSum << std::endl; 21 }
标签:std,cout,C++,toString,str,string,函数 From: https://www.cnblogs.com/gs590/p/16855244.html