Note: 2.1 Section to 2.2
Many people feel that the second chapter is difficult. The author also mentioned in the introduction of the first article: If the reader feels that the content of the second chapter is difficult to understand, he jumps out. And individual thinking is not the best choice, in fact, the first purpose is that there is a good overall understanding of this language, the habit of thinking, the formation of methodology is the focus of this chapter, in front of these nonsense, It is a simple explanation and suggestion for the difficulty we have to face and what we have to take.
Those things we are in the first chapter are more ready, can be used directly. It is not very limited by the syntax in the process of using it. I think everyone will remember that I am reading the data type. Have a question: Why did the author don't say arrays? In Section 2.1, the author gives an answer: arrays do not belong to basic types, what is the basic type? The author's explanation is that the language itself provides built-in support for this type of assignment, general arithmetic operation and relationship operation. Obviously array and pointers can not meet this condition, according to the author's original: they are not a first-class citizen,
About the knowledge points of these two sections. I don't want to say, there are not many, and those who have learned a few programs and pointers are not strange things. The author said in the preface of this book "This book is suitable for C beginners, but it is not suitable for the programming", but there are still two many initiaters who will commit to the low-level mistakes:
Array: I will give an example:
Int a [8] ;.
a [8] = 10;
These two 8 are almost identical. The fact is: in terms of meaning, the role is completely two things, the former is size, the latter is a subscript, here I have to produce a question: [] What is the operator? Here we have seen an example in which a consensus is used almost the first time (maybe not, just think so).
Pointer. I have seen a lot of usage similar to this:
INT * P = NULL;
COUT << * P << endl;
Obviously, a qualified programmer does not write such a code, but is not a friend's reminder. I also think that it thinks it can only be a fool error, there are two questions here: NULL is? I really tried it and ASCII before, in fact. It is 0. For a value given to the value. Next is the problem of spatial allocation, we all know that NULL's role is not to point the pointer to any space useful for the program. So 0 put it? Obviously, there is a misunderstanding of space, that is, the space of the pointer and the space pointing to the pointer is different. The space of the pointer is defined, but it can only place memory address and NULL (P), pointing space is something (* P) in the container, obviously, the above * P does not exist. Take a thing that does not exist, of course, you can't do it.
The author talks here in New. I have always been a little fear of New, and he is not as good as the function of c, the author tells us that it is an operator that is dynamically allocated. However, please note the author's explanation of dynamic allocation: "Running the behavior of the time library function". Library Functions? NO operator? Here we almost feel that there is some connection between functions and operators. In-depth thinking, think about the shortcomings of the array we mentioned at the beginning, can the array can't make certain operations? Well, if our assumption is established, the function and the operator is connected, then we can improve our array? It turns out that we are correct. This will lead ADT's idea - the design of class (later content is a process of continuous design and perfect). It can be seen that there is a big problem in our previous learning methods. We don't know why you have to learn the same thing, the author has suggests that our answer is. Demand triggers inspiration, inspiration, design, design achievement technology, and technology. Learn to meet the demand
http://blog.9cbs.net/owl2008/