- 论坛徽章:
- 0
|
感谢楼上, 可能是我没有叙述清楚。我所用的应该就是STL中的算法,而不是成员函数。
我的部分代码如下:(在BCB 以及 linux 中均无问题)
- #ifdef __BORLANDC__
- #pragma hdrstop
- #include <condefs.h>
- #include <conio.h>
- #else
- # define stricmp(a,b) strcasecmp((a),(b))
- #endif
- #include <iostream>
- #include <vector>
- #include <string>
- #include <fstream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define LN_BUF_SIZE 1024
- using namespace std;
- struct DKLrcdTYP
- {
- char YSDWSWJG[8]; // SWJGID="2220882"
- char FPHM[8];
- char KPRQ[12];
- char KPJE[12];
- char XFSWSBH[16];
- char GFSWSBH[16];
- bool operator < (const DKLrcdTYP &m)const
- {
- return (0>memcmp(YSDWSWJG,m.YSDWSWJG,16));
- }
- bool operator == (const DKLrcdTYP &m)const
- {
- return (0==memcmp(YSDWSWJG,m.YSDWSWJG,16));
- }
- bool operator > (const DKLrcdTYP &m)const
- {
- return (0<memcmp(YSDWSWJG,m.YSDWSWJG,16));
- }
- };
- bool less_XF(const DKLrcdTYP & m1, const DKLrcdTYP & m2)
- {
- return( 0>memcmp(m1.YSDWSWJG,m2.YSDWSWJG,16));
- }
- vector <struct DKLrcdTYP> FPdkl(0);
- vector <struct DKLrcdTYP> FPcgl(0);
- //---------------------------------------------------------------------------
- * * * * * *
- int main(int argc, char **argv)
- {
-
- chgDKL_HZ(); // 获取 n 个 数据 FPdkl.push_back(DKLrcd);
- sort(FPdkl.begin(), FPdkl.end(), less_XF);
- }
- * * * * * *
复制代码
[ 本帖最后由 hsia 于 2005-12-30 17:35 编辑 ] |
|