S
sean_in_raleigh
Hi,
I'm curious what the rationale was for two
oddities in C++.
1) Why did the standards committee choose
the oddball no-extension names for the standard
headers (<string>, e.g.)? I can understand them wanting to
emphasize that an included entity is not necessarily
a file, but they say "header file" throughout the standard,
and calling it something like "string.hpp" would not have implied
that it was necessarily a file.
2) Why was the following use of the conditional operator
made illegal?
class B { };
class D1 : public B { };
class D2 : public B { };
int main(int argc, char **argv) {
B *p1 = argc == 1 ? new D1() : new B();
B *p2 = argc == 1 ? new D1() : new D2();
}
In the code above, the p1 assignment is legal,
while the p2 assignment is not (according to
the standard's expr.cond.5, and the Comeau
and GNU compilers I tried). Why not just
treat it as the following:
B *p2;
if (argc == 1)
p2 = new D1();
else
p2 = new D2();
Thanks,
Sean
I'm curious what the rationale was for two
oddities in C++.
1) Why did the standards committee choose
the oddball no-extension names for the standard
headers (<string>, e.g.)? I can understand them wanting to
emphasize that an included entity is not necessarily
a file, but they say "header file" throughout the standard,
and calling it something like "string.hpp" would not have implied
that it was necessarily a file.
2) Why was the following use of the conditional operator
made illegal?
class B { };
class D1 : public B { };
class D2 : public B { };
int main(int argc, char **argv) {
B *p1 = argc == 1 ? new D1() : new B();
B *p2 = argc == 1 ? new D1() : new D2();
}
In the code above, the p1 assignment is legal,
while the p2 assignment is not (according to
the standard's expr.cond.5, and the Comeau
and GNU compilers I tried). Why not just
treat it as the following:
B *p2;
if (argc == 1)
p2 = new D1();
else
p2 = new D2();
Thanks,
Sean