中国开发网: 论坛: 程序员情感CBD: 贴子 74649
furnace
I found this template class from a opensource project, but I have no idea How to use it??
#include <cstddef>

template <class T, typename K> class objList
{

public:

static T* objFirst;
T* objNext;
K objKey;

objList(const K key)
{
objKey = key;
objNext = objFirst;
objFirst = (T *)this;
}

public:

static T* getObject(const K& key);

};

template <class T, typename K> T *objList<T, K>::objFirst = NULL;

template <class T, typename K> T *objList<T, K>::getObject(const K& key)
{
T *obj = objList<T, K>::objFirst;
while(obj)
{
if(key == obj->objKey)
break;
obj = obj->objNext;
}
return obj;
}
I don't mind if you r FAT.
I don't mind if you r UGLY.
I don't mind if you ACT CUTE.
But I can't STAND if you r FAT, UGLY and still ACT CUTE.

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录