+ 1

Why is the output 5 and not p2?

int a=5; int *p1 = &a; int **p2 = &p1; int ***p3 = & p2; cout << ***p3;

27th Jun 2018, 4:31 AM
Prashant Soni
Prashant Soni - avatar
2 RĂ©ponses
+ 4
Out put is 5 because: Firstly, p3 points to p2 Then, p2 points to p1 Then, p1 points to a Lastly, a is equal to 5 so p3 is also equal to 5 The ‘&’ symbol is a pointer used to point to a space p3 points all the way to a which is equal to 5
27th Jun 2018, 4:37 AM
Agent
Agent - avatar
+ 4
I think before understanding the output you should understand "what is pointers?" https://www.sololearn.com/learn/CPlusPlus/1630/
27th Jun 2018, 4:39 AM
Sudarshan Rai
Sudarshan Rai - avatar