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,
There is C++0x, which has the override 'annotation'. Or, if you wanted to achieve more of the Java "interface" like-code that errors if you don't implement methods, you could use an abstract class:
class Base {
public:
virtual void foo() = 0;
};
class Extended : public Base {
public:
void foo2() {
cout << "hi" << endl;
};
int main() {
Extended e;
e.foo();
}
This will result in a compiler error if you don't override foo in the base class. The issue, however, is that the base class can't have it's own implementation.