javac++annotations

Java-like annotations in C++


Is there something like Java's annotations in C++ ?

For example, the @Override annotation marks a function that it overrides another function, and if it wouldn't, it would give an error at compile time.

I am looking for something like this in C++.


Solution

  • C++11 has this feature, where you can explicitly (via the 'override' keyword) specify whether a member function is meant to override a base class' function. It also has additional features allowing a function to request a default implementation generated by the compiler (using '= default' syntax) or to not be defined (using '= delete' syntax), and much more.