문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top