C + + Summary __c++

Source: Internet
Author: User

Here is a summary of what I did in C + + when I was reading:

function

1, variable

Global variables (Contact): automatically initialized to 0

Local variables (Independence): must initialize before use, otherwise the result is unpredictable. Death after execution of the statement

Static local variables (to extend the lifetime of local variables): can be automatically initialized to 0, initialized only once. At the end of the program, death--the function is completed, its value can be retained, but not visible, for the next use.

2. Parameter transfer

Pass Value

Pass address (pointer)

Pass Reference (Reference)

3, return value

has return value: Returns statement

No return value: No returns statement, or NULL returned statement

4. Memory Space

Code area: Storing code

Global Data area: Global variables and static local variables

Heap area (using this space through new and delete): Dynamic Data,

Stack area: Local variables

Instruction pointer Register (CONTROL): Save the address I/O stream of the next instruction to be executed

Input stream extraction operation, read operation, input operation

Output stream insert operation, write operation, output operation

For you, like two pipes, the input stream is responsible for inputting to you, and the output stream is responsible for outputting from you.

Type of buffer

The buffer is divided into three types: full buffering, row buffering, and no buffering.

1, Full buffer

In this case, the actual I/O operation is completed when the standard I/O cache is filled. The typical representative of full buffering is the reading and writing of disk files.

2, line buffer

In this case, the actual I/O operation is performed when a newline character is encountered in the input and output. At this time, we entered the word Fuxian stored in the buffer, and so on press key to change the line before the actual I/O operation. The typical representative is the keyboard input data.

3, without buffer

That is, no buffering, standard error situation stderr is a typical representative, which makes the error message can be shown directly as soon as possible.

Heap Memory Release

C + + tells us to use delete[when retrieving the memory space of a single object allocated with new by using Delete to reclaim the memory space of a set of objects allocated with new[]:

1, New and delete

2, new[] and delete[]

3, generally speaking, the array is released with delete[], but the pointer is released only with delete[when it is an object of a class

The following is my drawing of the mind map, the painting is not very full, and the feeling is still very messy, but also need to properly organize

Click to see the big picture

















Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.