will be this initialization syntax valid in upcoming c++0x standard?
Suppose we have following two classes:
class Temp{
public:
char a;
char b;
};
class Final{
private:
int a;
char b;
char c;
public:
Final(Temp in):b(in.a),c(in.b){}
//rest of implementation
};
开发者_如何学编程
can we initialize an object of the Final class with following syntax in upcoming c++0x standard:
Final obj(Temp{'a','b'});
C++0x adds uniform initialization like for POD-struct and array types using braces ({}) for all types as well special initializer lists to support variable number of elements/arguments in them just like an array. So your example can be written as:
Final obj = { { 'a', 'b' } };
or
Final obj { { 'a','a' } };
精彩评论