这是一个使用Visual Studio 6编译的程序片段。但是在使用Visual Studio 2013编译后,我在以下行收到了错误。 我已经将错误语句粘贴在下面。
这在头文件中声明。
public:
Serial(tstring &commPortName, int bitRate = 115200, char *Name = NULL);
这是源文件中的内容
string COMport;
cout << "Enter the COM port (eg. COM1): ";
cin >> COMport;
tstring commPortName(COMport); //**ERROR AT HERE**
Serial serialDEVICE(commPortName, 115200, "DEVICE");
我遇到了以下错误。
Error 1 error C2664:
'std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>::
basic_string(std::initializer_list<_Elem>,const std::allocator<wchar_t> &)'
: cannot convert argument 1 from 'std::string' to 'const
第二个错误:
IntelliSense: no instance of constructor "std::basic_string<_Elem, _Traits,
_Alloc>::basic_string [with _Elem=wchar_t,
_Traits=std::char_traits<wchar_t>, _Alloc=std::allocator<wchar_t>]" matches
the argument list argument types are: (std::string)
我需要将tstring转换为string吗,以消除这个错误?