Error c2143: syntax error: Missing '; 'before''

Source: Internet
Author: User

Problem:

About error c2143: syntax error: Missing '; 'before' <class-head>' and its solution.

Explanation:

The meaning of this sentence is to add ";" in front of the class.

Error code:

# Include <iostream>
Using namespace STD;

# Define Max size 100
Typedef int datetype

Class sequenlist
{
PRIVATE:
Datetype data [maxsize];
Int Len;
Public:
Void initiate ();
Int length ();
Int insert (datetype X, int I );
Int delet (int I );
Int locate (datetype X );
Datetype get (int I );
};
Void sequenlist: initiate ()
{
Len = 0;
}
Int sequenlist: length ()
{
Return len;
}
Int sequenlist: insert (DateType x, int I)
{
Int j;
If (len> = maxsize ){
Cout <"overflow! \ N ";
Return 0;
} Else if (I <1) | (I> len + 1 )){
Cout <"position is not correct! \ N ";
Return 0;
} Else {
For (j = len; j> = I; j --)
Data [j] = data [j-1];
Len ++;
Return 1;
}
}
Int sequenlist: delet (int I)
{
Int j;
If (I <1) | (I> len )){
Cout <"position is not supported CET! \ N ";
Return 0;
} Else {
For (j = I; j <len; j ++)
Data [j-1] = data [j];
Len --;
Return 1;
}
}
Int sequenlist: locate (DateType x)
{
Int j = 0;
While (j <len) & (data [j]! = X ))
J ++;
If (j <len)
Return j + 1;
Else
Return 0;
}
DateType sequenlist: get (int I)
{
If (I <1) & (I> len ))
Cout <"position is not correct! \ N ";
Else
Return data [I-1];
}

Int main ()
{
 
Return 0;
}

 

 

Code after modification:

 

# Include <iostream>
Using namespace std;

# Define Max size 100
Typedef int DateType;

Class sequenlist
{
Private:
DateType data [maxsize];
Int len;
Public:
Void initiate ();
Int length ();
Int insert (DateType x, int I );
Int delet (int I );
Int locate (DateType x );
DateType get (int I );
};
Void sequenlist: initiate ()
{
Len = 0;
}
Int sequenlist: length ()
{
Return len;
}
Int sequenlist: insert (DateType x, int I)
{
Int j;
If (len> = maxsize ){
Cout <"overflow! \ N ";
Return 0;
} Else if (I <1) | (I> len + 1 )){
Cout <"position is not correct! \ N ";
Return 0;
} Else {
For (j = len; j> = I; j --)
Data [j] = data [j-1];
Len ++;
Return 1;
}
}
Int sequenlist: delet (int I)
{
Int j;
If (I <1) | (I> len )){
Cout <"position is not supported CET! \ N ";
Return 0;
} Else {
For (j = I; j <len; j ++)
Data [j-1] = data [j];
Len --;
Return 1;
}
}
Int sequenlist: locate (DateType x)
{
Int j = 0;
While (j <len) & (data [j]! = X ))
J ++;
If (j <len)
Return j + 1;
Else
Return 0;
}
DateType sequenlist: get (int I)
{
If (I <1) & (I> len ))
Cout <"position is not correct! \ N ";
Else
Return data [I-1];
}

Int main ()
{
 
Return 0;
}

 

Follow-up:

I read the code of a book. The typedef book didn't contain semicolons, which misled me.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.