我收到一条错误消息,说“T”没有命名类型。我对这意味着什么感到困惑。我以为我在课堂上宣布它说 Virtual T?
template <class T>
class ABList : public ABCList<T> {
private:
T a [LIST_MAX];
int size;
public:
ABList ();
virtual bool isEmpty ();
virtual int getLength ();
virtual void insert (int pos, T item);
virtual T remove (int pos);
virtual T retrieve (int pos);
};
.
T ABList::retrieve (int pos) throw (ListException)
{
if (pos <= 0 || pos >= count)
throw new ListException();
return item[pos – 1];
}