I'm trying to understand a few basics about extern, static, etc. and tried the following example, but I don't get why I can't call the function "just" because it's (possibly) inlined.
My first file : F1.cpp
#include <iostream> void Modify(); int i; int main() { i = 1; std::cout << "i = " << i << std::endl; Modify(); std::cout << "i = " << i << std::endl; return 0; } The second file : F2.cpp
#include <iostream> extern int i; inline void Modify() { i = 99; std::cout << "i = " << i << std::endl; } With inline keyword in F2.cpp, I get : undefined reference to Modify() in my F1.cpp file. Removing it, the code compiles and works fine.
I assume that the inline keyword in C++ has some sort of behaviour like the static keyword ?
I had a look at this topic aswell, but apart from the fact that the documentation says that an inline function should always be in the header file, I don't get it : C++ inline member function in .cpp file
Thanks for your help !