Head file with library files with rookie

zhaozj2021-02-16  48

Head file with library files with rookie

TAOWEN

First, this is exactly the personal experience I taught a rookie. Post here for the rookies to read, the content is shallow.

1. Why do I have anything such as cout as much as I include . I have seen Iostream, only some statements.

It is because the linker will link the standard library link to your program by default. And that library file (extension may be .LIB, .a), including the specific code compiled result (binary machine code). And This header is the key to open the library.

2. # include DO DO?

Just insert the content in <> or "" into the file. And you open the header file and then Ctrl-C, the effect of Ctrl-V is the same.

3. <> Is it the same as ""?

<> "" "Is almost. <> Find in the system directory (that is, the set of include directory), "" is to find in the directory where the project is located. For standard libraries, third-party libraries, etc., use <>. For other files in the same project, use "".

4. What is the #ifndef at the top of the header?

By #ifndef with #define to prevent the same file from being repeated

5. Do you have any problems with multiple include Include?

To see the situation. There is no problem with the function prototype. The actual implementation of the implementation of the function, the definition of the class is not. It is "only defined" principle, the statement can have multiple times.

6. I wrote a few CPP files and the corresponding header files in the same project. Why do I only contain the header file to use the content in the corresponding .cpp file?

Similar to #include , in the same project, the CPP files are compiled as target files (what .Obj or .o files), will be linked to your program.

7. What can I have to write a library written?

Writing a statement with the implementation in the same .HPP file (such as most of Boost).

Put the declaration and implementation in different files, provide .mak files to the user yourself, then set the include and lib directory (this generally used for the release of class libraries)

Do not release the compilation. LIB file is because its format is not unified. And the use of MAK files is also the dream of rookies.

In fact, I am also a rookie, these basic things I just understand. It is hoped that the masters can make an incorrect in time.

TAOWEN.CN.ST

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

New Post(0)