-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexternal_linkage.cpp
More file actions
19 lines (14 loc) · 874 Bytes
/
Copy pathexternal_linkage.cpp
File metadata and controls
19 lines (14 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
// Global variable forward declarations (extern w/ no initializer):
extern int g_z; // forward declaration for non-constant global variable
extern const int g_z; // forward declaration for const global variable
extern constexpr int g_z; // not allowed: constexpr variables can't be forward declared
// External global variable definitions (no extern)
int g_h; // defines non-initialized external global variable (zero initialized by default)
int g_h { 1 }; // defines initialized external global variable
// External const global variable definitions (extern w/ initializer)
extern const int g_h { 2 }; // defines initialized const external global variable
extern constexpr int g_h { 3 }; // defines initialized constexpr external global variable
int main(){
return 0;
}