June 2025
Intermediate to advanced
1093 pages
33h 24m
English
Because there can be so much confusion with namespace, using, and static, I will recapitulate the various usage scenarios here. For completeness, I will also include the type alias with using.
|
Language Element |
Description |
|---|---|
|
namespace xyz {…} |
New namespace xyz |
|
namespace {…} |
Anonymous namespace; all identifiers file-local |
|
inline namespace xyz {…} |
Embedded namespace |
|
static global variable |
File-local variable |
|
static free function |
File-local function |
|
static data field |
Shared between all instances of the class |
|
static method |
Method that you call without a specific instance |
|
static local variable |
A variable that persists beyond the scope |
|
using namespace xyz |
Import all identifiers ... |
Read now
Unlock full access