Example:
// header.h
void foo () // function definition in the file
{
}
// file1.cpp
#include"header.h"
...
// file2.cpp
#include"header.h"
...
Above code will result in linker error. Suppose if the compiler makes inline foo()
automatically then there will not be any linker error.
My question is on language perspective. Why the compiler doesn't make it inline
automatically ? Will it make any difference ?
Question in other words: "What wrong can possibly happens if compiler assumes inline
in front of every free function defined ?"