Java-like annotations in C ++

Is there something like Java annotations in C ++?

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

I am looking for something similar in C ++.

+26
source share
4 answers

C ++ 0x will have this function, where you can explicitly indicate whether a member function is intended to override a base class function, use the default implementation generated by the compiler, and much more.

+8
source

++ 0x, "". , "Java-" , , , :

    class Base {
public:
    virtual void foo() = 0;
};

class Extended : public Base {
public:

    void foo2() {
        cout << "hi" << endl;
};

int main() {
    Extended e;
    e.foo();
}

, foo . , , , .

+1

. , , , . "" .

0

Source: https://habr.com/ru/post/1780611/


All Articles