gcc - Scope of C libraries in C++ - <X.h> vs <cX> -


C ++ programming language: Special Edition 431 on page tells that ...

However, when I & lt; Cx> Style, I do not have to qualify for the namespace. For example ...

  #include & lt; Cmath & gt; Zero F () {double var = sqrt (17); }  

This will compile properly. Although the book says that & lt; The Cx> header defines the name only in the Steady namespace, you have permission to name those names without qualification. What am I missing here?

P.S. GNU Use of GCC compiler

MSWC team member Stephen T. Lovevage addresses the reality in this post (and some refinements for the standard) in this comment on your blog posting ():

> Also, & lt; Cstddef> , & lt; Cstdlib & gt; , and std :: size_t etc should be used!

I wanted to be very careful about that. C ++ 98 had a great dream in which & lt; Cfoo Namespace will declare everything in the CSS, and & lt; Foo.h & gt; in & lt; Cfoo & gt; and then drag everything in the global namespace with declarations (this is D5 [depr.c.headers].)

It was ignored by many implementers (of which There was little control over some standard standard library headers). Therefore, C ++ 0x has been changed to match reality. N2723 As a working paper, now & lt; Cfoo & gt; has guaranteed to declare everything within the namespace STD, and can not declare or declare things within the global namespace. & lt; Foo.h & gt; On the contrary: It is guaranteed to declare everything inside the global name space, and whether or not it can declare std under the name space.

In reality and C ++ 0x, in which & lt; Cfoo & gt; , everything is not safe with being declared in the global namespace. This is the reason i & lt; Cfoo & gt; .

I'm not bothered with. This library number was 456.

(C ++ 0x still rejects the headers from the standard library, which is sweltering.)

I am with Lavavej in the 100% agreement , Except that I have never tried to start using C ++ - even after & lt; Cfoo & gt; Be very careful about using style headers - Standard C was very limited - and they never had real world problems (and apparently < There was no real-world benefit to use / code> style headers.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -