@ForEveR
В астрале
7991 / 4750 / 321
Регистрация: 24.06.2010
Сообщений: 10,547
|
03.09.2012, 14:21
|
|
Из стандарта.
The ambiguity arising from the similarity between a function-style cast and a declaration mentioned in 6.8
can also occur in the context of a declaration. In that context, the choice is between a function declaration
with a redundant set of parentheses around a parameter name and an object declaration with a function-style
cast as the initializer. Just as for the ambiguities mentioned in 6.8, the resolution is to consider any construct
that could possibly be a declaration a declaration. [ Note: A declaration can be explicitly disambiguated by
a nonfunction-style cast, by an = to indicate initialization or by removing the redundant parentheses around
the parameter name. — end note ] [ Example:
C++ | 1
2
3
4
5
6
7
8
9
| struct S {
S(int);
};
void foo(double a) {
S w(int(a)); // function declaration
S x(int()); // function declaration
S y((int)a); // object declaration
S z = int(a); // object declaration
} |
|
2
|