Question: This question was at the interview:
*Does this code causes any compile/linking errors and why so?*

```
template <int T> void f();
template <> void f<0>() {}

void test() 
{
    f<1>();
}

```

Please explain the behaviour. Thanks a lot.

Answer: 
It will compile (all the code is gramatically valid) but will fail at link stage.

This is because `template <int T> void f();` is declared but *not* defined, the <0> specialisation *is* defined but that makes no odds to you since you're not instantiating it.

Actually, it *would* be possible for the <0> specialisation to contain syntax errors and the program *would* still compile without error! This is because formally, templates are only compiled if they are used. (I wouldn't expect a candidate to have the presence of mind during interview conditions to point that out.)
It will compile because compiler can see a declaration for a generic template. There is a fully specialized template for 0 also. But we are calling it for 1, which will try to invoke the generic template, but since linker cannot find any definition for the general template, the program will show linker error.

Soloution

```
template <int T> void f();
template <> void f<0>() {}
template <int T> void f() { }

void test() 
{
  f<1>();
}

```