开发者

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' } };
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜