extern const can not be used together

Reprinted to: https://www.cnblogs.com/herenzhiming/articles/5442893.html

Often variable must be initialized when defined, so when you define a.cpp the extern const double pi = 3.14; b.cpp in extern const double pi; When the compiler system finds a.cpp the global constant variable, you know it is the constant pi, and change over time, as defined in a.cpp in const double pi = 3.14; b.cpp in extern const double pi; build system at compile a.cpp is no problem, but in the b.cpp You will find that there is an external constant is not initialized, and the constant is not defined in the declaration and then, so the compiler can not find the system will consider its definition, so wrong.

Guess you like

Origin www.cnblogs.com/tangmiao/p/11288533.html