看《数据结构与算法分析》,用书上的代码创建线性表的顺序表。
可是编译出现错误,求解答。
AList.h
 #include <list>
template < class Elem >
class AList : public List<Elem>
{
private:
    int maxSize;
    int listSize;
    int fence;
    Elem* listArray;
public:
    AList(int size=DefaultListSize)
    {
        maxSize = size;
        listSize = fence = 0;
        listArrary = new Elem[maxSize];
    }
    ~AList(void)
    {
        delete [] listArrary;
    }
    void clear()
    {
        delete [] listArrary;
        listArrary = fence = 0;
        listArrary = new Elem[maxSize];
    }
    bool insert(const Elem&);
    bool append(const Elem&);
    bool remove(Elem&);
    void setStart()
    {
        fence = 0;
    }
    void setEnd()
    {
        fence = listSize;
    }
    void prev()
    {
        if(fence != 0)
            fence--;
    }
    void next()
    {
        if(fence <= listSize)
            fence++;
    }
    int liftLength() const
    {
        return fence;
    }
    int right() const
    {
        return listSize - fence;
    }
    bool setPos(int Pos)
    {
        if((Pos >= 0) && (Pos <= listSize))
            fence = pos;
        return (pos >= 0) && (pos <= listSize)
    }
    bool getValue(Elem& it) const
    {
        if(rightLength() == 0)
            return false;
        else
        {
            it = listArrary[fence];
            return true;
        }
    }
    void print() const
    {
        int temp = 0;
        cout<<"< ";
        while(temp < fence)
            cout<<listArrary[temp++]<<" ";
        cout<<"| ";
        while(temp < listSize)
            cout<<">\n"
    }
};
AList.cpp
 #include "AList.h"
template <class Elem>
bool AList<Elem>::insert(const Elem& item)
{
    if(listSize == maxSize)
        return false;
    for(int i=listSize;i>fence;i++)
        listArrary[i] = listArrary[i-1];
    listArrary[fence] = item;
    listSize++;
    return true;
}
template <class Elem>
bool AList<Elem>::append(const Elem& item)
{
    if(listSize == maxSize)
        return false;
    listArrary[listSize++] = item;
    return true;
}
template <class Elem>
bool AList<Elem>::remove(Elem& it)
{
    if(rightLength() == 0)
        return false;
    it = listArrary[fence];
    for(int i=fence;i < listSize-1;i++)
        listArrary[i] = listArrary[i+1];
    listSize--;
    return true;
}
编译错误为:alist.h(4): error C2143: 语法错误 : 缺少“,”(在“<”的前面)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
#include
using namespace std; //加上这句
template < class Elem >
class AList : public list
或者
#include 
template < class Elem >
class AList : public std::list //改成这样