Navnish Garg
Navnish Garg

Reputation: 103

In C++, macro usage before semicolon in function declaration

Can anyone please explain me the following code:

    #ifndef SOME_DEF
        #define SOME_DEF
    #endif

    class base_class{    
        public:
        base_class() SOME_DEF;

        ~base_class() SOME_DEF;

        bool init(int arg1, int arg2) SOME_DEF;

    };

I am not able to understand the usage of macro after every function.

Upvotes: 0

Views: 320

Answers (1)

Jts
Jts

Reputation: 3527

In your case, it does nothing, unless SOME_DEF is already defined somewhere else, for example:

#define SOME_DEF { cout << "default definition" << endl; }

If SOME_DEF is defined like that, then every function in your class that includes SOME_DEF will have that body.

Upvotes: 1

Related Questions