我在写程序的时候,使用到了模板类,但是不会用,出现了错误,还请过来的高手指点一二
template<class T,int MAX_SIZE>
class STemplateObjMan
{
public:
DWORD FreeHead;
SObj* GetNew();
BOOL FreeObj(SObj*);
T* operator ++(int ){return (T*)GetNew();}
T* operator ++() {return (T*)GetNew();}
//...
}
//...
template <class T,int MAX_SIZE>
SObj* STemplateObjMan<T,MAX_SIZE>::GetNew()
{
if(FreeHead == -1) //没有空余的资源供使用,只能返回空值
return NULL;
//..
}
出现了错误,错误是
d:\mytest\netpart\sobj.h(91) : error C2143: syntax error : missing ')' before ';'
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class CANDATA,10000>::GetNew(void)'
d:\mytest\netpart\sobj.h(91) : error C2059: syntax error : ')'
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class CANDATA,10000>::GetNew(void)'
d:\mytest\netpart\sobj.h(92) : warning C4390: ';' : empty controlled statement found; is this the intent?
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class CANDATA,10000>::GetNew(void)'
d:\mytest\netpart\sobj.h(98) : error C2143: syntax error : missing ')' before ';'
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class CANDATA,10000>::GetNew(void)'
d:\mytest\netpart\sobj.h(98) : error C2059: syntax error : ')'
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class CANDATA,10000>::GetNew(void)'
d:\mytest\netpart\sobj.h(99) : warning C4390: ';' : empty controlled statement found; is this the intent?
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class CANDATA,10000>::GetNew(void)'
d:\mytest\netpart\sobj.h(91) : error C2143: syntax error : missing ')' before ';'
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class SIOData,100>::GetNew(void)'
d:\mytest\netpart\sobj.h(91) : error C2059: syntax error : ')'
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class SIOData,100>::GetNew(void)'
d:\mytest\netpart\sobj.h(92) : warning C4390: ';' : empty controlled statement found; is this the intent?
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class SIOData,100>::GetNew(void)'
d:\mytest\netpart\sobj.h(98) : error C2143: syntax error : missing ')' before ';'
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class SIOData,100>::GetNew(void)'
d:\mytest\netpart\sobj.h(98) : error C2059: syntax error : ')'
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class SIOData,100>::GetNew(void)'
d:\mytest\netpart\sobj.h(99) : warning C4390: ';' : empty controlled statement found; is this the intent?
d:\mytest\netpart\sobj.h(52) : while compiling class-template member function 'class SObj *__thiscall STemplateObjMan<class SIOData,100>::GetNew(void)'
SObj.cpp
还请那位高手指教