-
"pointer" is a simplification.
Pointer – Address.
Pointer Variable - The variable that holds the address.
It's all called a pointer. You need to distinguish what this "pointer" refers to in each context.
-
The pointer definition type is used for the purpose of taking values and pointer operations.
1. The essence of a pointer is a memory address. Regardless of the type of pointer, it is essentially a memory address.
2. Define the pointer type, which can be more convenient to obtain values.
No matter what pointer is defined or what kind of address is saved, the purpose is not to obtain the address value, but to access the data on the address.
By defining the pointer type, you can easily get the data.
If the pointer p is long*, then when *p is used, it is the value of four consecutive bytes of data at the address where the p value is used.
And if the p type is char
type, then *p is used
It's a byte of data at the address p.
3. Define the pointer type to facilitate pointer operation.
With a pointer, the most common operation is to move the pointer, that is, to add or subtract. By adding and subtracting the pointer, it is easy to access the same type of unit that is adjacent or indirectly adjacent. For the same p+1, the actual number of bytes of memory moved by different pointers is different, and its value is sizeof.
Namely. For type
p;The actual offset address value of p+n is sizeof(type)*n.
-
While all pointers take up only four bytes, different types of variables take up different bytes.
In general, int takes up four bytes and char takes up one byte.
If the pointer variable is defined without defining the type, then it doesn't know how many bytes it should read when it takes *, that is, the value in it.
And after defining the type. If it is int, it reads four bytes, and char reads one byte.
-
C++ knows the length very easily, which is why the pointer needs a pointer specific type.
Since it is int*, then the type of pointing is of course int, so the length must be the size of int.
C++ is a statically typed language, and the type of all variables needs to be specified during compilation.
-
1.The size of the pointers, the size of all pointers is 32 bits, and sizeof(int*) and sizeof(double*) are both equal to 4
2.The size of the pointer to memory is not fixed, and this size is stored in the process memory management linked list, which is currently not available in the user-level programming.
3.Pointer access.
Actually, you can think of it as *p = p[0]; The specific access method depends on the type definition of your p pointer, and the compiler will generate different assemblies according to different types**, e.g. int may be one mov, double may be two mov, if it is a class variable it may call the copy constructor, etc.
-
The system doesn't know, it's the compiler that knows.
The int* and double* types are different, and the compiler checks the type at compile time and processes accordingly to generate different machine code instructions.
-
In C++, the pointer stores the address, and the address points to a certain area of memory, where a certain value is stored, or that block of memory stores a set of data with consecutive addresses, such as an array.
The pointer of C++ stores the address, which means that the pointer itself also occupies memory, if it does not occupy memory, then where is the address stored? So you define a pointer that takes up memory.
For example, there is an integer variable called a, which stores the number 1, then we use an integer pointer to point to the address of this variable a, and the pointer value you said is the value of this variable a, that is, the number 1
Memory is one of the most important components of a computer, and it is the bridge that communicates with the CPU. The running of all programs in the computer takes place in memory, so the performance of the memory has a very large impact on the computer. >>>More
Yes, DIMMC1: 128M PC2100 DDR SDRAM
dimmc2:128m pc2100 ddr sdram >>>More
Friend, I can tell you with great certainty that there are lower ones. >>>More
The card is actually related to the CPU If your CPU is not more than dual-core, it will be carded The video memory required by the graphics card is 64M After all, it is a 2D game The memory is best DDR2 1G or more You see which one you have not reached the standard And the network speed is also very important As for which one you want to change See which one does not meet the standard.
Hello. First of all, insurance and banks cannot be directly compared, because both are national financial institutions, each with its own path of existence and development, and its functions and focus in society are different. >>>More