error C2143: syntax error : missing ';' before 'using'

c++, static

Solution

After preprocessing, your source code[1] for your "header definition" becomes like

// iostream contents

// iomanip contents


class Math
{
    private:
        static enum names {amin = 27 , ali = 46};

    public:
        static void displayMessage();

}

using namespace std;

void Math::displayMessage()
{
    cout<<amin<<setw(5)<<ali<<endl;
}

Let's now see `error C2143: syntax error : missing ';' before 'using'`. Where is `using` in the above code? What is it before `using`?

}
^ This    

using namespace std;

Because of the part of the error that says `missing ';'`, we must add that missing `;`.

};
 ^

[1] More precisely called a "translation unit".

Problem

this is my header: ``` #ifndef HEADER_H #define HEADER_H class Math { private: static enum names {amin = 27 , ali = 46}; public: static void displayMessage(); } #endif // HEADER_H ``` and this is the header definition: ``` #include <iostream> #include <iomanip> #include "Header.h" using namespace std; void Math::displayMessage() { cout<<amin<<setw(5)<<ali<<endl; } ``` and this is the main: ``` #include <iostream> #include "Header.h" using namespace std; enum Math::names; int main() { Math::displayMessage(); } ``` i got these errors: ``` error C2143: syntax error : missing ';' before 'using' error C2143: syntax error : missing ';' before 'using' ``` one of them is for main and the other is for header definition, i have encountered several time in my programming, could explain that for me in this situation, please help me best regards Amin khormaei

Original source

Related problems