Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/160.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在visualc++; 有人能解释C++中如何将单词转换成字符串吗? typedef struct _appversion { WORD wVersion; CHAR szDescription[DESCRIPTION_LEN+1]; } APPVERSION; // Some code APPVERSION AppVersions; // At this point AppVersions structure is initialized properly. string wVersion; wVersion = AppVersions.wVersion; // Error // Error 1 error C2668: 'std::to_string' : ambiguous call to overloaded function wVersion = std::to_string((unsigned short)AppVersions.wVersion); VisualC++环境中的< > >代码> Word < /C> >是未签名短 >的类型定义。< /P>_C++_Visual C++ - Fatal编程技术网

如何在visualc++; 有人能解释C++中如何将单词转换成字符串吗? typedef struct _appversion { WORD wVersion; CHAR szDescription[DESCRIPTION_LEN+1]; } APPVERSION; // Some code APPVERSION AppVersions; // At this point AppVersions structure is initialized properly. string wVersion; wVersion = AppVersions.wVersion; // Error // Error 1 error C2668: 'std::to_string' : ambiguous call to overloaded function wVersion = std::to_string((unsigned short)AppVersions.wVersion); VisualC++环境中的< > >代码> Word < /C> >是未签名短 >的类型定义。< /P>

如何在visualc++; 有人能解释C++中如何将单词转换成字符串吗? typedef struct _appversion { WORD wVersion; CHAR szDescription[DESCRIPTION_LEN+1]; } APPVERSION; // Some code APPVERSION AppVersions; // At this point AppVersions structure is initialized properly. string wVersion; wVersion = AppVersions.wVersion; // Error // Error 1 error C2668: 'std::to_string' : ambiguous call to overloaded function wVersion = std::to_string((unsigned short)AppVersions.wVersion); VisualC++环境中的< > >代码> Word < /C> >是未签名短 >的类型定义。< /P>,c++,visual-c++,C++,Visual C++,因此,您可以使用std::to_string执行此任务: wVersion = std::to_string(AppVersions.wVersion); 编辑: Visual Studio 2010显然不完全支持C++11功能,请改用std::stringstream: std::stringstream stream; stream <<AppVersions.wVersion; wVersion = stream.str(); std::stringstream; s

因此,您可以使用
std::to_string
执行此任务:

 wVersion = std::to_string(AppVersions.wVersion); 
编辑: Visual Studio 2010显然不完全支持C++11功能,请改用
std::stringstream

std::stringstream stream;
stream <<AppVersions.wVersion;
wVersion  = stream.str();
std::stringstream;

stream@Petesh我正在尝试您的解决方案,并收到此错误
错误1错误C2668:'std::to_string':对重载函数的调用不明确…
有什么线索可以修复它吗?谢谢我正在尝试您的解决方案,并得到此错误
error 1 error C2668:'std::to_string':对重载函数的调用不明确…
有什么线索可以修复它吗?谢谢它在我的Visual Studio 2013上编译得非常完美,但我想您可以添加显式强制转换,例如
到_string((unsigned short)myWord))
此外,请确保包含标题,例如
#include
是否使用Visual Studio 2010?@Dimi您可以尝试强制转换为
到_string
直接支持的类型,我想试试
int