Why is it that I can include a header file in multiple cpp files that contains const int and not have a compiler error?

Posted by tree on Stack Overflow See other posts from Stack Overflow or by tree
Published on 2012-04-01T23:09:56Z Indexed on 2012/04/01 23:29 UTC
Read the original article Hit count: 198

Filed under:
|
|
|

Let's assume that I have files a.cpp b.cpp and file c.h. Both of the cpp files include the c.h file. The header file contains a bunch of const int definitions and when I compile them I get no errors and yet I can access those const as if they were global variables. So the question, why don't I get any compilation errors if I have multiple const definitions as well as these const int's having global-like scope?

© Stack Overflow or respective owner

Related posts about c++

Related posts about compilation