I have two cpp files :
F1.cpp
using namespace std;
int i;
void Modify();
int main()
{
i=1;
cout << "i main 1 = " << i << endl;
Modify();
cout << "i main 2 = " << i << endl;
return 0;
}
F2.cpp
using namespace std;
extern int i;
inline void Modify()
{
i=99;
cout << "i modify = " << i << endl;
}
When I launch the executable I get this error : F1.o: In function main : F1.cpp:(.text+0x4a): undefined reference to `Modify()' collect2: error: ld returned 1 exit status
I don't understand why this is happening since the point of an inline function is that the code is copy pasted when the function is called. So when I call Modify() in my main method, I would think that it would paste the code of the Modify() function there, therefore I don't understand why there would be an undefined reference...
Please help!