inline functions


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.
if you have inlined functions, you should have the body in the header file
You don't need to to make it inline, but it might be better coding to signify in both.
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.