#include<iostream.h> #include<string.h> template <class TElem> class TLinearList0 { protected: public: long len; //属性,表示线性表的长度。 virtual TElem & Get(long idx)=0; virtual TElem * Set(long idx,TElem & elem)=0; virtual TElem * Prior(long idx)=0; virtual TElem * Next(long idx)=0; virtual TElem * GetAddress(long idx)=0; virtual long CountELem(TElem & elem)=0; virtual long Locate(TElem & elem,long sn=1)=0; virtual long Locate(TElem & elem,long * foundElem)=0; virtual long LocateFirst(TElem & elem)=0; virtual long LocateNext(TElem & elem)=0; virtual TElem * Insert(TElem & elem,long sn=1)=0; virtual TElem * Delete(long sn=1)=0; }; template <class TElem> class TLinearListSqu : public TLinearList0<TElem> //派生类。 { protected: TElem *room; //room相当一维树组,其元素类型为可变类型TElem long size; long lastVisited; TElem buffElem; long ResizeRoom(long newSize); long CopyRoom(TElem * objRoom,long nl,TElem * srcRoom,long n2); public: TLinearListSqu(void); TLinearListSqu(long mSize); ~TLinearListSqu(void); virtual TElem & Get(long idx); virtual TElem * GetAddress(long idx); virtual TElem * Set(long idx,TElem & elem); virtual TElem * Prior(long idx); virtual TElem * Next(long idx); virtual long CountElem(TElem & elem); virtual long Locate(TElem & elem,long sn=1); virtual long Locate(TElem & elem,long * foundElemIndex); virtual long LocateFirst(TElem & elem); virtual TElem * Insert(TElem & elem); virtual TElem * Delete(long sn=1); virtual long DeleteByIndex(long * idxTobeDel,long numIdx,TElem * elemDeleted=NULL); void Print(); }; //初始化 template<class TElem> TLinearListSqu<TElem>::TLinearListSqu() { size=0; len=0; room=NULL; }; template<class TElem> TLinearListSqu<TElem>::TLinearListSqu(long mSize) { size=0; room=NULL; len=0; if(mSize<1) throw TExceLinearList(2); room=new(nothrow) TElem[msize]; if(room==NULL) throw TExcepLinearList(3); size=mSize; }; template <class TElem> TLinearListSqu<TElem>::~TLinearListSqu(void) { if(room!=NULL)delete[]room; }; //元素直接访问 //实现访问和存储 template <class TElem> TElem & TLinearListSqu<TElem>::Get(long idx) { if(idx<0||idx>=len) throw TExcepLinearList(1); return room[idx]; };
就是下面的函数,一编译就出问题。 TElem *TLinearListSqu<TElem>::GetAddress(long idx) { if(idx<0||idx>=len) throw TExcepLinearList(1); return &room[idx]; };
请帮帮我!!!