C ++ skill learning notes (1)

xiaoxiao2021-03-05  23

First, file structure

(1) Header file: Declaration for storage procedures.

(2) Definition file: Used to store the implementation of the program.

The header file consists of three parts: (1) Copyright and version declaration at the beginning of the header (see Example 1-1). (2) Preparation block. (3) Functions and class structure declarations.

(1) Copyright and version of the statement copyright and version declaration.

Located on the beginning of the definition file and declaration file.

format:

(1) Copyright information. (2) File name, identifier, summary. (3) Current version number, author / modifier, complete date. (4) Version history information. / ** Copyright (C) 2005, Wooden Studio * All Rights Reserved. * * File Name: FileName.h * File ID: See Configuration Management Program * Summary: Summary: Summary of this document * * Current version: 1.1 * Author: Enter the author (or modified) Name * Completion date: July 20, 2005 ** Replacement Version: 1.0 * Original Author: Enter the original author (or modifier) ​​Name * Completion Date: May 2005 10th * / (2) Pretreatment module.

[Rule 1-2-1] In order to prevent the header files from being repeatedly referenced, the preparation block should be generated using the IFNDEF / DEFINE / ENDIF structure. [Rule 1-2-2] with #include

Format to reference the standard library's header file (the compiler will start searching from the standard library directory). [Rule 1-2-3] Use a #include "filename.h" format to reference the unbalanced base file (the compiler will start searching from the user's working directory).

[Recommendation 1-2-1] Only "declaration" is stored in the header file without storing "definition"

(3) Function and class structure declaration.

Define the composition of the file:

(1) Define the copyright and version declaration at the beginning of the file (see Example 1-1). (2) Quote for some headers. (3) The implementation of the program (including data and code).

If a software's header file is more (such as more than ten), the header file and definition file should usually be saved in different directories for maintenance.

For example, the header file can be saved in the include directory, and the definition file is saved in the Source directory (which can be a multi-level directory).

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

New Post(0)