c++ 如何定义结构体/定义类,求长度函数/求长度方法,按位置求值函数/按位置求值方法,插入函数/插入方法【在最后位置插入】,删除元素函数/删除元素方法
1. 定义结构体/定义类
typedef int elementType;
typedef struct sList
{
elementType data[MAXLEN];
int len; //有效长度
} seqList;
2. 初始化函数/
void initList(seqList * L) {
L->len = 0;
}
3. 求长度函数/求长度方法
void SeqList<Type>::show_list()
{
for(int i=0; i<size; ++i)
{
cout<<base[i]<<" ";
}
cout<<endl;
}
4. 按位置求值函数/按位置求值方法
void SeqList<Type>::insert_pos(int