0

Recently, I gave an interview and I was stuck at this question. Question he asked was as follows,

How many indirection level I can have in c++?

After interview, I tried following in c++ code and everything worked.

int i = 0;

int *p1 = & i;

int **p2 = & p1;

int ***p3 = & p2;

int ****p4 = & p3;

int *****p5 = & p4;

*****p5=1; 
cout<<i;//output 1

How far can I go like this? Does C++ impose any limit on number of indirection level? If yes, what is it?

Abhishek
  • 6,912
  • 14
  • 59
  • 85

0 Answers0