High quality programming guide-C/C ++ chapter 7th C/C ++ pointers, arrays and strings

Source: Internet
Author: User

Chapter 3 C/C ++ pointers, arrays, and strings
7th pointers
1. Pointers are addresses, that is, the addresses of the variables pointed to by the pointer.
2. a void * type pointer can be assigned a value to any type of pointer. Therefore, it cannot be used in arithmetic operations and can only be assigned, compared, or sizeof () operations.
array 7.2
1. The array name is actually the first address of the array.
2. Semantics of Delete and delete.
3. Avoid using arrays in modern c ++ Programs . Instead, use vector .
7.3 character array, character pointer, and string
1. Concept
character array: array of char element type, it may or may not contain the string end flag '\ 0 '.
string: it is also a character array and must end with the string ending sign '\ 0.
character pointer: char *, a pointer to a string. Note: The database function used to operate the string considers the character pointer to be a string containing the string end sign '\ 0.
2. Avoid using character arrays and character pointers in modern c ++ programs. Instead of string.
7.4 function pointer
1. function pointer is the address of the function. In C/C ++, the function name represents the function address. Therefore, you can assign a function name to a function pointer of the same type.
2. General function pointer
3. class member function pointer
7.5 Comparison Between Reference and pointer
remember that when I graduated to work, in the interview questions I saw on the Internet, I often had such questions. At that time, I had to answer them.
references and pointers are actually two different concepts. I can't tell the difference fluently, but it seems that I can tell the difference between them in actual use.
it is easy to misunderstand: the creation and destruction of references do not call class constructors and destructor. references are only aliases of objects (variables) and are not real objects.
the reference is mainly used to modify the form parameters and return values of a function.

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.