Pointers to pointers in C ++
A pointer to a cursor is an unidirected form or a string of pointers. Typically, a pointer contains the address of a variable.
A pointer to a cursor is an unidirected form or a string of pointers. Typically, a pointer contains the address of a variable. When we define a pointer to a pointer, the first pointer contains the address of the second pointer, which points to the location that contains the actual value shown in the diagram below:
A variable, which is a pointer to a pointer, must be declared. This is done by placing an asterisk (*) in front of its name. For example, the following is a pointer to a pointer to an int:
int ** var ;
When a target value is pointed by a pointer to a pointer, accessing that value requires that the asterisk operator be applied twice, as in the example:
#include using namespace std ; int main () { int var ; int * ptr ; int ** pptr ; var = 125 ; // lay dia chi cua var ptr = & var ; // lay dia chi cua ptr boi su dung dia chi cua toan tu & pptr = & ptr ; // Lay gia tri boi su dung pptr cout << "Gia tri cua var la: " << var << endl ; cout << "Gia tri tai *ptr la: " << * ptr << endl ; cout << "Gia tri tai **pptr la: " << ** pptr << endl ; return 0 ; }
Running the above C ++ program will produce the following results:
According to Tutorialspoint
Previous article: Array of pointers in C ++
Next lesson: Pass the cursor to the function in C ++
You should read it
- Cursor in C / C ++
- Cursor to class in C ++
- Array of pointers in C ++
- How to Create Pointers in C
- Arithmetic pointer in C / C ++
- Cursor in C
- Cursor NULL in C / C ++
- Cursor and Array in C ++
- How to Check Null in C
- How to keep the default desktop icons and mouse pointer when changing the Windows 11 theme
- Operator in PHP
- Boolean operators AND and OR in SQL
Maybe you are interested
Things you should and shouldn't do when wearing red lipstick 10 strange and interesting facts about the universe you may not have heard of The burial chamber of the deceased due to Covid-19 in Iran is large enough to be seen from space New technology helps NASA find water, self-sufficient food on the moon Six versions of Half-Life and Half-Life 2 are being played for free, please experience 4 simple steps to clean the shower