Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
while compiling this cpp file getting the compilation error.


C++
class A final
{
public:
    A()
    {
        cout<<"Inside A()"<<endl;
    }

};
/*class B:public A
{
public:
    B()
    {
           cout<<"Inside B()"<<endl;
    }
};*/

int main(int argc, char *argv[])
{
    A obj;
 // QCoreApplication a(argc, argv);
  cout<<"inside main";
  getchar();
  return 0;
  // return a.exec();

}


and my .pro file looks like this
QT += core
QT -= gui

Qt5:
@CONFIG += c++11@

or Qt4:
@CXXFLAGS += -std=c++11@


TARGET = CPP11
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
Posted
Updated 28-Nov-15 6:07am
v2
Comments
PIEBALDconsult 28-Nov-15 12:13pm    
Do you plan to tell us the compilation error?
bijaynayak 28-Nov-15 12:16pm    
C2470: 'final' : looks like a function definition, but there is no parameter list; skipping apparent body

PIEBALDconsult 28-Nov-15 12:20pm    
OK, so what does that usually mean?
bijaynayak 28-Nov-15 12:27pm    
PIEBALDconsult,
I am expecting that it will not give any compilation process....

1 solution

Remove the '@' characters from your project file:
CONFIG += c++11

When using GCC, check the compilation output window if the C++11 option is passed to the compiler (-std=c++11). When using Visual C++ (which seems to be case according the error code), it must be VS 2012 or later because older versions did not support final.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900