gpt4 book ai didi

c++ - 错误 C2664 : 'bool Strless::operator ()(const TCHAR *&,const TCHAR *&) const' : cannot convert parameter 1 from 'wchar_t *const ' to 'const TCHAR *&'

转载 作者:行者123 更新时间:2023-11-28 01:07:19 31 4
gpt4 key购买 nike

我正在为系统中的编译错误而苦苦挣扎,这是代码

struct Strless : public binary_function<TCHAR*, TCHAR*, bool>
{
public :

bool operator()(const TCHAR* & _Left, const TCHAR* & _Right) const
{
int iVal = _tcscmp(_Left, _Right);

return (iVal < 0)? true:false;
}


}; map<TCHAR *, int, Strless> mymap;

最佳答案

你的 const 放错地方了。 map 向您传递了 TCHAR* const,但您使用的是 const TCHAR*&,这两者不兼容。你想要一个 const TCHAR* const&

关于c++ - 错误 C2664 : 'bool Strless::operator ()(const TCHAR *&,const TCHAR *&) const' : cannot convert parameter 1 from 'wchar_t *const ' to 'const TCHAR *&' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5475576/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com