C ++ novice must ask head file

zhaozj2021-02-17  65

[result]

Issue questions about the C header files in the technical forum of 9CBS and other other. It is often the newcomers who have just learned C . I also asked similar problems when I was a rookie.

Take a look at the following two include:

#include // This is the standard header file after 1998 standardization.

#include // This is a standardized header file.

Early nature is that iostream puts the components of the standard C library in the Namespace of a list of STDs. The relative Iostream.h places these standard components in the global space, while the old C standard library has been transformed after standardization.

Take a look at the two headers below

/ / After the standardization of the modified C standard library, all components are placed in STD.

#include

// Standardized C Standard Library in C

#include

/ / Take a look at the Char *-based character processing function library under this header file C standard library

#include

// He became like this after normalization

#include

/ / But many friends have also seen this string handling library, he contains new string class

#include

After the standard committee so large-scale surgery, the C compiler (BC3.0, BC5.0) before 98 years can be successfully passed through the compiler, and may not be able to pass compilation on the compiler supporting the new standard. It is also normal.

[cause]

When you go back to see the standard library, this library covers a wide range, which has mentioned how much better use. It is precisely because the Class names in the standard library and the function name and the Class name in the library provided by the third party or the function name have increased. In order to avoid this problem, the Standards Committee decided to put everything in the standard library in Namespace STD. But doing this, there is a new problem. Many C program code rely on those C "quasi" standard libraries that have existed many years (C delay is not standardized to cause these conditions), such as iosteam.h, complex.h, and so on.

In order to solve this new problem, the Standardization Committee decided to design some new header names to use components that put on the STD coat. Remove the C header file. H, then there is a front appearance of iostream, the same C's header file has also done the same processing, while adding a letter C in front to represent C's header file (feeling The feeling of racial discrimination). At the same time, the standardization committee statement will not be listed in the supported list, and the old C header files will continue to survive in order to meet the "compatibility of C".

However, those compilers cannot go to overthrow their customers' old compilers (and will not go to do this), so those old C headers are still lively living, and constantly disrupt those C new soldiers The mind.

Below is now most C development tools indicate the organization status of the header file:

1. Old C header files such as iostream.h, although they are abandoned by the Standardization Commission, but due to the major manufacturers will continue to survive, the contents of these headers will not be in Namespace STD.

2. New C header files such as iostream although provided with the same features as the old head file, his content is incorporated in Namespace STD, which effectively avoids the problem of name pollution. 3. Standard C header files such as stdio.h continue to support, the content of such files is not placed in the STD.

4. The skill of the C function library also has a corresponding new C version, and the name is similar to CSTDIO. The content of this header file is also fortunate to put on the STD coat.

In fact, the standardization library after standardization is not only these, and many standardized components are "TAMPLATE". Among them, there is a veteran character. The problem of standard libraries is not used, two articles can be clear. If you know the C standard library, you can look at Mr. Hou's "C Standard Library".

[references]

Stanley B.Lippman is translated by Pan Aimin, C Primer, 3rd Edition, China Electric Press, 2002.

SCOTT Meyers, Hou Jie, Effective C , 2nd Edition, Huazhong University of Science and Technology Published, 2001.

转载请注明原文地址:https://www.9cbs.com/read-29535.html

New Post(0)