Header files define the class:
#include
using namespace std;
Const int MaxSize=100;
Template
The class SeqList
{
Public:
SeqList () {length=0; }
SeqList (T a [], int n);
~ SeqList () {}
Int length () {return length; }
T Get (int I);//by a lookup
Int the Locate (T, x);//by value lookup
Void Insert (int I, T, x);
T Delete (int I);
Void PrintList ();
Private:
T data [MaxSize];
};
Template
SeqList & lt; T> : : SeqList (int n)
{
int i;
If (n> MaxSize)
Cout<& lt;" Parameters of the illegal ";
for(i=0; i
Length=n;
}
Template
Void SeqList
{
int j;
If (length>=MaxSize)
Cout<& lt;" Overflow ";
If (i<1 | | i> Length + 1)
Cout<& lt;" Abnormal position ";
For (j=length; J>=I; J -)
Data [j]=data [j - 1);
Data [I - 1]=x;
Length++;
}
Template
T SeqList
{
Int j, x;
If (length==0)
Cout<& lt;" Underflow ";
If (i<1 | | i> Length)
Cout<& lt;" Abnormal position ";
X=data [I - 1);
for(j=i; J
Length -;
Return the x;
}
Template
T SeqList
{
If (i<1 | | i> Length)
Cout<& lt;" Find illegal ";
The else return data [I - 1);
}
Template
Int SeqList
{
int i;
for(i=0; i
return 0;
}
Template
Void SeqList
{
If (I==0)
Cout<& lt;" Underflow ";
for(i=0; i
Then the main function:
#include
using namespace std;
Int main ()
{
SeqList
Supachai panitchpakdi rintList ();
S.I nsert (3, 8);
Cout
Spyware doctor elete (5);
Cout
return 0;
}
Then the error display:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the Configuration: exe - Win32 Debug -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Compiling...
Cc. CPP
D: \ Microsoft visual studio \ myprojects \ exe \ seqlist h (32) : error C2244: 'SeqList
D: \ Microsoft visual studio \ myprojects \ exe \ seqlist h (33) : error C2954: template definitions always nest
D: \ Microsoft visual studio \ myprojects \ exe \ cc CPP (6) : error C2664: '__thiscall SeqList
Reason: always convert from 'const int' to 'const class SeqList
No constructor could take the source type, or constructor overload resolution was ambiguous
An error occurred when executing cl. Exe.
Exe. Exe - 1 error (s), and 0 warning (s)
CodePudding user response: