1. Variable:
------------
int A;
------------
This isn't a Declaration, but also a Definition.
Since It is a defintion, it's must "Define only once".
----------------------Example------------------
If you write the this in a. h file, and included it everywhere ...
We know that ' #include ' means extracted the original file totally here, so the same Var int a have been defined as many Ti Mes as been included, which is invalid.
Ps:compile is OK, since it's local, local in the specific CPP file. When Complier was working on this file, he Dosen ' t know even a bit information the world outside.
So the generated file, O is also local.
However, Link is not OK. For multi definition error of int a.
2.Function:
-------------
void f ();
-------------
So you can declare it many times, everywhere. This is just a name. Comile and Link are both OK.
Define Variable in a. h file, "static" "extern" "Const" ... are needed.
Definition and Declaration