Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Rationale for t...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 43291 of 47977
Post > Topic >>

Rationale for two C++ features

by sean_in_raleigh@[EMAIL PROTECTED] Feb 13, 2008 at 10:49 AM

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
 




 10 Posts in Topic:
Rationale for two C++ features
sean_in_raleigh@[EMAIL PR  2008-02-13 10:49:21 
Re: Rationale for two C++ features
Rolf Magnus <ramagnus@  2008-02-13 21:10:23 
Re: Rationale for two C++ features
Pete Becker <pete@[EMA  2008-02-13 15:21:15 
Re: Rationale for two C++ features
Jeff Schwab <jeff@[EMA  2008-02-13 12:30:05 
Re: Rationale for two C++ features
Jeff Schwab <jeff@[EMA  2008-02-13 12:31:35 
Re: Rationale for two C++ features
"Bo Persson" &l  2008-02-13 21:56:18 
Re: Rationale for two C++ features
James Kanze <james.kan  2008-02-14 02:39:39 
Re: Rationale for two C++ features
Hendrik Sattler <post@  2008-02-16 11:37:29 
Re: Rationale for two C++ features
Ron Natalie <ron@[EMAI  2008-02-15 22:08:13 
Re: Rationale for two C++ features
James Kanze <james.kan  2008-02-16 11:14:15 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 8:34:55 CDT 2008.