Domanda

We don't need to declare inline functions explicitly since their implementations are defined in a header file. But for organization purpose, I want to do it. For example

// Group declaration firstly for readability.
inline void fooA();
inline void fooB();
inline void fooC();
...

// Implementations
inline void fooA()
{
   ...
}

inline void fooB()
{
   ...
}

inline void fooC()
{
   ...
}

My question is: may I need both inline keywords in declaration and implementation or one of them can be deleted?

I found an answer there Forward declaration of inline functions . So this is a repeated question. Sorry about that.

È stato utile?

Soluzione

You need to include it in either the declaration, the definition, or both.

But note that the definition must be visible in every compilation unit that uses the function.

Altri suggerimenti

You don't need both. You can delete inline keyword in implementation and keep inline keyword when you declare functions... It is same as virtual keyword

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top