C++11 type initial more convenient such as
??
Vector<int> VEC = {A-i};
Vector<int> vec{1,2,3};
Map<string, int> m = {{"Help", 3}, {"Good", 4}};
??
Other common examples include how a class that you define accepts list initialization
struct class supports simpler initialization in C++11 without the use of handwritten initialization functions
Class Node
{
Public
int x;
Double y;
String Z;
};
??
Class Vec
{
Public
VEC (const initializer_list<double>& IL)
:d ATA (IL)
{
??
}
Vector<double> data;
};
??
??
TEST (Simple, func)
{
Node node{1, 3.5, "Meixi"};
Pval3 (node.x, Node.y, node.z);
??
Vec vec{1.2, 3.4, 5.6};
Pvec (Vec.data);
}
??
I0512 11:41:11.497020 2240 test_simple.cc:51] node.x--[1] node.y--[3.5] node.z--[Meixi]
I0512 11:41:11.497115 2240 test_simple.cc:54] Vec.data---3
I0512 11:41:11.497122 2240 test_simple.cc:54] 0 1.2
I0512 11:41:11.497128 2240 test_simple.cc:54] 1 3.4
I0512 11:41:11.497134 2240 test_simple.cc:54] 2 5.6
? ?
Initialization of the C++11