This code:
#include <iostream>
using namespace std;
struct k
{
static int ii;
static void foo();
};
void k::foo() {
ii=0;
}
int main() {
// your code goes here
return 0;
}
gives a linking error, because the function k::foo is output by the compiler, and it references k::ii.
This code:
#include <iostream>
using namespace std;
struct k
{
static int ii;
inline static void foo();
};
inline void k::foo() {
ii=0;
}
int main() {
// your code goes here
return 0;
}
does not give a linking error, because the function k::foo is declared inline and is not called from anywhere, so the compiler never actually produces any code for it.
If you add a call to k::foo() inside main, or anywhere else, then you will get a linking error.