关于RArray排序问题

RacoXu 2007-11-15 11:57:58
我查了一些资料,想对RArray数组做一个排序。具体如下:
自己定义了一个T类:
class TNoteData
{

public: // constructor

TNoteData() {};//: iStrength(50){};

public: // members

TBool IsValid() const;
TBuf<200> iContent;
TBuf<20> iTime;
public: // accessors

void SetContent(const TDesC& aContent);
const TDes& Content() const;

void SetTime(TDesC& aTime);
const TDes& Time() const;
void SetTimeNow();
private: //Data

};
在Container.h文件中声明了:
RArray<TNoteData> iNoteList;
在Container.cpp文件中增加了函数:
TInt CompareTime(const TNoteData& note1,const TNoteData& note2)
{
if(note1.iTime>note2.iTime)
return 1;
else if(note1.iTime==note2.iTime)
return 0;
else
return -1;
}
在Container.cpp文件需要调用的函数中增加了:
TLinearOrder<TNoteData> order1(CompareTime);
iNoteList.Sort(order1);


但在编译时提示错误:
C:\WORK\NOTE\SRC\Notecontainer.cpp(237) : error C2664: '__thiscall TLinearOrder<class TNoteData>::TLinearOrder<class TNoteData>(int (__cdecl *)(const class TNoteData &,const class TNoteData &))' : cannot convert parameter 1 from 'int (const class
TNoteData &,const class TNoteData &)' to 'int (__cdecl *)(const class TNoteData &,const class TNoteData &)'
None of the functions with this name in scope match the target type
Error executing cl.exe.
我看了几个例子都是这么写的,为什么我的不行?请教这是什么原因造成的?
...全文
77 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
RacoXu 2007-11-16
  • 打赏
  • 举报
回复
ok,谢谢!
dyw 2007-11-15
  • 打赏
  • 举报
回复
CompareTime是static函数吗?尝试改成static函数。
dyw 2007-11-15
  • 打赏
  • 举报
回复
比较函数必须是静态函数.
RacoXu 2007-11-15
  • 打赏
  • 举报
回复
请问二位应该如何修改呢?
anel 2007-11-15
  • 打赏
  • 举报
回复
明显输入参数类型不对

3,120

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧