inline functions

Apr 4, 2009 at 1:32pm

In headers, if an inline function is declared inline in its implementation .cpp file, do i also need to add the inline keyword to the prototype in the .h file as well? It seems to compile either way.
Apr 4, 2009 at 1:36pm
if you have inlined functions, you should have the body in the header file
Apr 4, 2009 at 1:37pm
You don't need to to make it inline, but it might be better coding to signify in both.
Apr 4, 2009 at 2:11pm
If the function is implemented in the .cpp file and not the header file, then the function can be inlined only in the translation unit in which it is visible (ie, the .cpp file where it is implemented).

Move it to the header file.

And some compilers do complain even in the same header file if the function is declared inline but then it's implementation does not have the keyword inline on it (or vice versa).

Topic archived. No new replies allowed.