I am a bit puzzled about this. When default stack allocated object construction is allowed as member varaiable of other struct, why not parameterized construction ? Does Most Vexing Parse has anything to do with this ? I tried on C++0X as well at ideone and got the same result.
struct foo{
foo() {}
foo(int i) {}
};
struct bar{
foo obj; // Allowed
foo obj2(10); // Not Allowed
};
Error: expected ‘,’ or ‘…’ before numeric constant
Your link to Most Vexing Parse discusses instantiation of non-member variables (variables which are not a member of a class/struct). The example you’ve shown is that of member variables being declared in a struct; for which you would typically initialise them in a constructor
The Most Vexing Parse problem occurs in situations such as the below:
where the identifier
meowappears to be a function declaration of typebaz (int), due to the ‘most vexing parse’ issues described in your link. (the int() which at first glance appears to be default-initialisation actually turns out to be simply the data typeint)