int dd=1;
int *a=ⅆ // 1
int *c=new int[2]; //2
这里1说明a是int 类型的指针,2说明c是int数组类型的指针.对不?
这段数据结构代码
两个理解:
1.rowlist是个动态数组指向一大块内存,数组里的元素存储着指向LinkList<int>链表的地址。即rowlist是指针数组。如图一
2.rowlist指向一个内存,这个内存存储着<LinkList< int > * >类型的指针,即rowlist是指针的指针。如图二
感觉两个都可以,是要看具体实现吗。比如rowlist=new ...是采用第一种?
The subject said:
That’s not the case, a and c are actually the same thing, they are pointers to int. c is not a "pointer of type int array".
Why is c originally an int pointer, but it can actually point to an int array? Because when the int array is assigned to the int pointer, the C language secretly converts it (the int array) into the first element of the int array. The professional term for this "sneak conversion" is called "implicit conversion".
So to summarize:
The variable c is not a pointer of type int array, but a pointer of type int;
Then why variable c can point to an int array? It’s because there is an implicit conversion;
c is a pointer to int. Pointer to array should be written as
How many bytes will the pointer +1 move? Give it a try.