[C++17] Inline Variable

in #coding6 years ago

Pattern

inline auto var = [value];


Description

C++ consist a lot of source files. They are compiled, linked into single binary file. When linking, it occurs error when you defined some symbols multiple time. The traditional solution is to declare symbol in the header files, then the definition will be done once for each source file which has included the header files. This is called One Definition Rule. In C++17, there is another way to solve this. inline keyword can be in front of variables. Compiler can implement variables by inline keyword, which the variable will be redefined where it is called.

Coin Marketplace

STEEM 0.28
TRX 0.13
JST 0.032
BTC 61138.54
ETH 2920.26
USDT 1.00
SBD 3.54