首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

C++函数调用的有关问题,请进

2012-03-15 
C++函数调用的问题,请进!菜鸟问一下:templateClassTclassCSt{public:staticintIComp(constvoid*,constvo

C++函数调用的问题,请进!
菜鸟问一下:

template   <Class   T>

class   CSt
{
public:
    static   int   IComp(const   void   *,const   void   *);
   
    void   St(T   inf);

    void   *   Sea(T   inf,int   i);
}

template <Class   T>
void   CSt <T> ::St(T   inf)
{
    T   *t=(T   *)Sea(inf,IComp);//为什么IComp函数没有参数?这是怎么一个使用方法?

......
}

如果改成标准C的程序该怎么改?

谢谢!!!



[解决办法]
在那里看到的代码?
Sea的实现呢?
[解决办法]
如果改成标准C的程序该怎么改?
====>
C没有模板, 没有类, 难:)
[解决办法]
/* bsearch example */
#include <stdio.h>
#include <stdlib.h>

int compareints (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}

int values[] = { 10, 20, 25, 40, 90, 100 };

int main ()
{
int * pItem;
int key = 40;
pItem = (int*) bsearch (&key, values, 6, sizeof (int), compareints);
if (pItem!=NULL)
printf ( "%d is in the array.\n ",*pItem);
else
printf ( "%d is not in the array.\n ",key);
return 0;
}


[解决办法]
#define T ??

T *t=(T *)Sea(inf,IComp(??, ??)); //没有参数是不对的 ...

热点排行