views:

70

answers:

1

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'});
+2  A: 

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' } };
snk_kid
thanks body, I think that feature's gonna be awesome !!!
Pooria