Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

C++11 override keyword support

speedy_code
Beginner
871 Views

Hi,

i was under the impression that the keyword "override" was supported by version 13.0 of the intel compiler, but I am getting the following error (my code is copied directly from cppreference: http://en.cppreference.com/w/cpp/language/override). Thanks very much for the help. 

struct A

{

  virtual void foo();

  void bar();

};

 

struct B : A

{

  void foo() const override; // Error: Has a different signature from A::foo

  void foo() override; // OK: base class contains a virtual function with the same signature

  void bar() override; // Error: B::bar doesn't override because A::bar is not virtual

};

int main()

{

  return 0;

}

icpc -std=c++11 Main2.C -o test

Main2.C(9): error: expected a ";"

    void foo() const override; // Error: Has a different signature from A::foo

                     ^

 

Main2.C(10): error: expected a ";"

    void foo() override; // OK: base class contains a virtual function with the same signature

               ^

 

Main2.C(11): error: expected a ";"

    void bar() override; // Error: B::bar doesn't override because A::bar is not virtual

               ^

 

compilation aborted for Main2.C (code 2)

0 Kudos
1 Reply
Judith_W_Intel
Employee
871 Views
The c++11 final and override keywords will not be supported until the next release. This is what our (currently under development) compiler prints (as expected) on your test program: sptxl8-321> icpc -c -std=c++11 foo.cpp foo.cpp(9): error: member function declared with "override" does not override a base class member void foo() const override; // Error: Has a different signature from A::foo ^ foo.cpp(11): error: member function declared with "override" does not override a base class member void bar() override; // Error: B::bar doesn't override because A::bar is not virtual ^ compilation aborted for foo.cpp (code 2)
0 Kudos
Reply