Technically, there is no difference.
Although I know little about optimization with them, think about it ...
The preprocessor will first expand the .h file, where it will find #include in the .cpp file. And then it will be presented to the compiler. So technically there is no difference.
But there is a rule:
The an inline function must be defined in each compilation unit in which it is called. (Of course, ODR should be respected).
This is because each compilation unit is processed by a separate instance of the compiler program.
Therefore, usually an inline function is defined in the header file, which is included in each .cpp file in which there is a call to this function.
source share