Question: Sorry guys I know my english is bad, but i made examples so that my question is more clearer.  

**a.cpp**  

```
#include <iostream>

using namespace std;

void funcfoo(){
    cout << "test only" << endl;
}

int varfoo = 10;

```

**b.cpp**

```
#include <iostream>

using namespace std;

extern void funcfoo();

extern int varfoo;

int main(){

    funcfoo();

    cout << varfoo;

    return 0;
}

```

**Then I compile it like this "cl b.cpp a.cpp"**  

My question is. How come when I remove the "extern keyword before void funcfoo()" it works fine, but when i remove the extern keyword
before int var foo I get an error?

Answer: 
The issue is what each one of the lines of code means. `int varfoo` is a **definition** of a variable, while `void funcfoo()` is only a **declaration**. You can provide multiple declarations of an entity, but only one *definition*. The syntax to provide a *declaration* and only a *declaration* of a variable is by adding the `extern` keyword: `extern int varfoo;` is a *declaration*

---

> 
> 3.1 [basic.def]/2 A declaration is a definition unless it declares a function without specifying the function’s body (8.4), it contains the extern specifier (7.1.1) or a linkage-specification25 (7.5) and neither an initializer nor a function body [...]
> 
> 
>
Another way to think about it is that when you do int varfoo memory is allocated to hold the variable so it is both a definition and a declaration, when you do int foo() the function is declared but not defined so in a way the memory is not allocated. For functions the linkage is external by default so removing it doesn't matter but for the variable, if you say extern int varfoo the compiler will not allocate memory for it --it will assume that the variable is defined somewhere else.