#include <iostream>using namespacestd;//ADTtemplate<classT>classseqlist{ Public: //constructor FunctionSeqlist () { This->length =0; This->data =NULL;} Seqlist (intlength); Seqlist (intlength,t array[]); //Increase intPush (T data);//Enter (Stack/team) and return the length of the new array intUnshift (T data);//similar to queue, enter from team header, and return the length of the new array//DeleteT pop ();//out of the stack and returns the element valueT shift ();//out of the team and return the element value at the//Check intLength ();//returns the array length BOOLIncludes (T data);//queries whether the element exists in the array intIndexOf (T data);//returns the subscript for this valueT ValueOf (intindex);//returns the value corresponding to the subscript//(fix) ChangeT replacevalueof (intindex);//Replace the value with the subscript and return the original value at that point intReplaceindexof (T data);//Follow//Sort voidSort ();//Default ascending order voidSortintTYPE);//0: Ascending, 1 reverse//Reverse voidreverse (); ~seqlist (); Private: T*data; intlength;}; Template<classT>seqlist<t>::seqlist (intlength) { if(length>-1){ This->length =length; This->data =NewT[length]; }Else{ Throw "warning:argument ' length ' is invalid!"; }}template<classT>seqlist<t>::seqlist (intlength,t array[]) { if(length>-1){ This->length =length; This->data =NewT[length]; }Else{ Throw "warning:argument ' length ' is invalid!"; } for(intI=0;i< This->length;i++){ This->data[i] =Array[i]; } printf ("Constructor has completed!"); } //Enter (Stack/team) and return the length of the new arraytemplate<classT>intSeqlist<t>::p ush (T data) {return 0; }//similar to queue, enter from team header, and return the length of the new arraytemplate<classT>intSeqlist<t>:: Unshift (T data) {return 0;}//out of the stack and returns the element valuetemplate<classT>T seqlist<T>::p op () {}//out of the team and return the element value at thetemplate<classT>T seqlist<T>:: Shift () {}template<classT>intSeqlist<t>::length () {//returns the array length return This-length;} Template<classT>BOOLSeqlist<t>::includes (T data) {//queries whether the element exists in the array return true;} Template<classT>intSeqlist<t>::indexof (T data) {//returns the subscript for this value return 0;} Template<classT>T seqlist<t>::valueof (intIndex) {//returns the value corresponding to the subscript returnNULL;}//(fix) Changetemplate<classT>T seqlist<t>::replacevalueof (intIndex) {//Replace the value with the subscript and return the original value at that point returnNULL;} Template<classT>intSeqlist<t>::replaceindexof (T data) {//Follow return 0;}//Sorttemplate<classT>voidSeqlist<t>::sort () {//Default ascending order ;} Template<classT>voidSeqlist<t>::sort (intTYPE) {//0: Ascending, 1 reverse ; } //Reversetemplate<classT>voidSeqlist<t>:: Reverse () {;} Template<classT>seqlist<t>::~seqlist () {Delete[] This-data;} intMain () {seqlist<int>demo (2); cout<<Demo. Length (); return 0;}
C + + sequential list (stack/queue, etc.) ADT