Complete learning C + + reading route map (2)

Source: Internet
Author: User

pointers, arrays, types of recognition, variable parameters of the function.

I. Pointers.

Its essence is the type of address. In many languages there is no such concept at all. But it is the reason why C is flexible, efficient, and invincible in the process-oriented era. Because C's memory model basically corresponds to now von Neumann (von. Neumann) machine model of computer, well achieved the mapping to the machine. But some people never seem to understand the pointer "note 1". "

Note 1:joel Spolsky think so, he believes that the understanding of the pointer is a aptitude, not through training can be achieved HTTP://WWW.JOELONSOFTWARE.COM/PR .../fog0000000073.html

Pointers can point to values, arrays, functions, and of course, they can also be used as values.

Look at the following examples:

int* p;//p is a pointer that points to an integer

int** p;//p is a pointer that points to the second pointer and then to an integer

int (*PA) [3];//pa is a pointer that points to an array of 3 integers

Int (*PF) ();//PF is a pointer to a function that returns an integer

In the fourth section, I will explain the identification of the identifier (identifier) type in detail.

1. What is the type of the pointer itself?

Let's look at the following example: What is the type of int a;//a?

Yes, just get rid of a. Therefore, the type of the pointer itself in the 4 declaration statements above is:

int*

int**

Int (*) [3]

Int (*) ()

They are all compound types, that is, types combined with types. The meanings were as follows:

point to Int (pointer to an integer)

Pointer to pointer to int (pointer to a pointer to an integer)

Pointer to array of 3 ints (pointing to a pointer to an array with three integers)

Pointer to function ' parameter is void ' and return ' value is int (pointer to a function, this function argument is NULL, returned value is an integer)

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.