Thursday, August 7, 2014

The `override` Keyword in C++11

Since C++11 has been released, a lot of new things are added in newer versions of working draft (available at Recently I've come to know about the `override` keyword (which is not actually a `keyword` but an identifier with a special meaning).

A very good description with code example is given in this link below,

Key points are,
  1. Works with virtual functions.
  2. The identifier `override` makes sure that the base class has the same function signature if you write override specifier after some virtual function in derived class.
  3. Quoting working draft C++11 N3242 (published on 28-Feb-2011),
    If a virtual function is marked with the virt-specifier override and does not override a member function of a base class, the program is ill-formed.

No comments :

Post a Comment