CList::Find的问题,请教
八月 3, 2007
发表在: java
大概的代码如下:
typedef struct t_dll_list
{
char szdllname[200];
hinstance *hinst;
}dll_list_t;
clist<t_dll_list, t_dll_list&> list;
但是在用find方法的时候有问题.
position searchchains(char* pdllname)//
{
t_dll_list tt;
strcpy(tt.szdllname,pdllname);
return list.find(tt,null);
}
错误是:
--------------------configuration: testdlg - win32 debug--------------------
compiling...
testdlgdlg.cpp
d:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(122) : error c2678: binary == : no operator defined which takes a left-hand operand of type const struct t_dll_list (or there is no acceptable conversion)
d:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(1036) : see reference to function template instantiation int __stdcall compareelements(const struct t_dll_list *,const struct t_dll_list *) being compiled
generating code...
compiling...
testdlg.cpp
generating code...
error executing cl.exe.
testdlg.exe - 1 error(s), 0 warning(s)
请问各位,怎么解决?谢谢
电脑软件技术推荐:
就是说,你这个list中的结构t_dll_list不支持==操作符。
因此,需要为这个结构增加==操作符函数
typedef struct t_dll_list
{
char szdllname[200];
hinstance *hinst;
bool operator ==(t_dll_list tdl)
{
if(strcmp(szdllname,tdl.szdllname) != 0)
return false;
if(hinst != tdl.hinst)
return false;
return true;
}
}dll_list_t;
为t_dll_list实现一个operator==(cosnt t_dll_list& rhs)
.
No comments in this entry