Initialization
C++ 的初始化方式可以分成很多種, 七種 Initializer :
Default initialization
Value initialization, e.g. std::string s{};
Direct initialization, e.g. std::string s(“hello”);
Copy initialization, e.g. std::string s = “hello”;
List initialization, e.g. std::string s{‘a’, ‘b’, ‘c’};
Aggregate initialization, e.g. char a[3] = {‘a’, ‘b’};
Reference initialization, e.g. char& c = a[0];
兩種 Static initialization:
Static initialization
Dynamic initialization
兩種 Dynamic non-local initialization:
Ordered dynamic initialization
Unordered dynamic initialization
兩種 Class member initialization:
Member initializer list
in-class brace-or-equal initializer