Chapter 4 data abstraction
The so-called data abstraction mainly focuses on struct and class. This chapter details the origins of the class and the specific procedures and causes of its conversion from struct. Read carefully to have a deeper understanding of the class.
The knowledge points in this chapter are concentrated and difficult to explain. There are many programming ideas and methods, so this time we will not write "recommendation points". instead raised several questions here, to facilitate reading as much as possible. If you can answer all these questions, you will have mastered the main content of this chapter. This chapter can be quickly passed over. Otherwise, you can select the part you are interested in and read it with questions. This gives you more directionality during reading.
1What is the storage principle of heap?
For example, a string can be filled in with strings without a limited space, while a vector can be set to whatever type it is willing to put. How can we achieve this?
You can get the answer from the first program instance.
2. structWhat is the difference with class?
C ++Why should I use class instead of struct? (Where is the superiority of class, but is it actually different from struct ?).
This is the center of this chapter.
3. # ifdef # ifndef # endifWhat is it?
Here, by the way, # pragma once is introduced in the new standard, which can be replaced by # ifndef and # endif in the header file. It is easier to write.
# The Pragma family also has many other features. For more information, see.
4. Void * pointer operation
How can I convert the void * type to int * or char * output as needed? What is the role and value of the void * pointer?
You will be able to understand these examples in this chapter.
I only want to write so much, I hope it will help you.