C ++ learning note 2 - 3.3 pointer type

zhaozj2021-02-16  52

1. Each pointer has a related type. The difference between the pointers of different data types is not on the representation of the pointer, nor is the value held by the pointer - all types of pointers are the same. of. Different from the type of object referred to in the pointer, the type of pointer can indicate how the compiler explains the content of memory on a particular address and how many memory cells should be across the memory area.

2. "INT * P1, P2;" and "INT * P3, * P4" are different. P1 is a pointer, P2 is an integer. Both P3, P4 are pointers.

3. The pointer cannot be initialized or assigned the address value of other types of objects. It is not to say that there is no other type of memory address: it can, but not allowed, because although the same address value can be held, the interpretation of the memory layout and content of the memory is completely different.

4. The pointer inspection will reduce efficiency and often determine what the value will be in the execution period. Note to the pointer: always initialize the pointer, do not ignore the error message or warning information issued by the compiler, such as: Forcing Convert to Pointer Variables, etc.

转载请注明原文地址:https://www.9cbs.com/read-24484.html

New Post(0)