constants.cpp
static const double g_gravity(9.8
main.cpp
#include<iostream>
extern const double g_gravity; // will not find g_gravity in constants.cpp because g_gravity has a internal linkage.
int main(){
std::cout<<g_gravity; // will compile error because g_gravity has not been a defined as far as main.cpp knows
return 0;
}
global.cpp:
int g_x(2); // external linkage by default
main.cpp
extern int g_x; // forward declaration for g_x -- g_x can be used beyond this point this file
int main(){
std::cout<<g_x; // should print 2
return 0;
}