Difference between putting variables in header vs putting variables in source

Posted by Mohit Deshpande on Stack Overflow See other posts from Stack Overflow or by Mohit Deshpande
Published on 2010-04-15T22:29:15Z Indexed on 2010/04/15 22:43 UTC
Read the original article Hit count: 579

Filed under:
|
|
|

Say I declare a header file with a variable:

int count;

Then in the source file, I want to use count. Do I have to declare it as:

extern int count

Or can I just use it in my source file? All assuming that I have #include "someheader.h". Or should I just declare it in the source file? What is the difference between putting count in the header file vs the source file? Or does it not matter?

© Stack Overflow or respective owner

Related posts about header

Related posts about source-file