Trouble using 'override' keyword
-
Hello there,
I am having trouble using the override keyword in one of my methods. Here is the code:
@
void NBhistoryInterface::addHistoryEntry(const QString & url) override
{
qDebug() << "SLOT: NBhistoryInterface::addHistoryEntry(const QString & url) override STATUS: Called";
addHistoryItem("Title", url);
qDebug() << "SLOT: NBhistoryInterface::addHistoryEntry(const QString & url) override STATUS: Completed";
}
@The program won't compile and gives this error:
"expected function body after function declarator"What am I doing wrong? Thanks!
-
Have you enabled C++11 support?
-
It depends on your compiler. MSVC 2013 enables it by default.
For GCC 4.8, you need to add this to your .pro file:
@
CONFIG += c++11
@ -
Hi,
There's no compiler coming with Qt Creator. The only "exception" if we can say, is the MinGW package which also provides the compiler.
-
When you click the green Run button, Qt Creator simply runs whatever compiler you've installed and asked it to use.
To check the compiler you're using, click on the "Projects" button on the left.
Also, go to Tools -> Options -> Build & Run -> Kits to see all the compiler+Qt versions available on your computer.
-
Try, as JKSH suggested, to add @CONFIG += c++11@ to .pro file.
If the error will stay the same then clang (whatever version you have) does not support this particular feature of C++ 11.If you will see a different error then probably the clang supports C++ 11.
And the error will tell you that you put override into wrong place.
It suppose to be in a "function declaration":http://en.cppreference.com/w/cpp/language/override and you have it in a definition.[EDIT] It can be specified at function definition but only if the definition is inside a class.