代码先行:
template <typename T>
void do_sth(int count)
{
char str_count[10];
//...
itoa(count, str_count, 10);
//...
}
但是我遇到了这样的编译错误:
error: there are no arguments to ‘itoa’ that depend on a template parameter, so a declaration of ‘itoa’ must be available
error: ‘itoa’ was not declared in this scope
但我确实包括了<cstdlib>
.
谁能告诉我哪里出了问题?
最佳答案
itoa 似乎是一个非标准函数,并非在所有平台上都可用。请改用 snprintf(或类型安全的 std::stringstream)。
关于c++ - 模板函数中的 itoa,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7461451/