yungman
- 5,741
- 294
I am really not good in the terms and all that. Let me just say what I understand. If this still have problem, then I have to learn more:
1) int*ptr is a pointer that can only point to an address of an integer variable. ptr is the address, you can do ptr =&x where x is an integer. for double, const, you use: double dbt; double *ptr=&dbt etc.
2) for pointer to pointer. use int**pptr. pptr can only be address of a pointer. pptr cannot equal to &x. It's ok for pptr=&ptr. eg. int*ptr; int**pptr; pptr=&ptr; &ptr is the address of ptr.
I don't know why they use int**pptr. It is not ok to point to an integer variable. pptr has to be address of a pointer like ptr. Like it is legal to wtite pptr=&ptr.The confusion is I said address is an integer. This is NOT saying address is classified as int as you think in C++. All I am saying is address has to be a whole number, no fraction. It cannot even be -ve integer. You know there is a clear meaning of INTEGER outside of C++, that's what I was using for, not in terms of int in C++. Integer is just a whole number with no fraction, not int in C++.Don't read the other posts as I might said things wrong in terms of using names. If there is anything wrong with what I said here, let me know. to me, this is crystal clear now.
1) int*ptr is a pointer that can only point to an address of an integer variable. ptr is the address, you can do ptr =&x where x is an integer. for double, const, you use: double dbt; double *ptr=&dbt etc.
2) for pointer to pointer. use int**pptr. pptr can only be address of a pointer. pptr cannot equal to &x. It's ok for pptr=&ptr. eg. int*ptr; int**pptr; pptr=&ptr; &ptr is the address of ptr.
I don't know why they use int**pptr. It is not ok to point to an integer variable. pptr has to be address of a pointer like ptr. Like it is legal to wtite pptr=&ptr.The confusion is I said address is an integer. This is NOT saying address is classified as int as you think in C++. All I am saying is address has to be a whole number, no fraction. It cannot even be -ve integer. You know there is a clear meaning of INTEGER outside of C++, that's what I was using for, not in terms of int in C++. Integer is just a whole number with no fraction, not int in C++.Don't read the other posts as I might said things wrong in terms of using names. If there is anything wrong with what I said here, let me know. to me, this is crystal clear now.