8 C++
8.1 Initialization
- 直接初始化
3 + 4;
in a = int a(3+4); //int a (3+4) is also okay, but you'd better remove the space
int a{3 + 4}; //int a {3 + 4}; is also okay
int a = {3 + 4}; // the same as above
int * i = new int(1);
double * d = new double{1.2f}
int a[] = {1, 3, 4};
int b[] {2, 4, 6};
int> c{1, 3, 5};
vector<int, float> d = { {1, 1.0f}, {2, 2.0f}, {5, 3.2f} }; map<
- 间接初始化
// construct a temp variable and copy that to `s`
"Hello") string s=string(
8.2 tips
typeid(1.2).name(); cout <<