Avatar ·

How many levels of pointer indirection can there be in C++?

Hi everyone. I've been writing in C++ for about a year, and one theoretical question has been bothering me. I know you can create pointers to pointers, like `int** ptr`, and even triple pointers `int*** ptr`. But how far can you go? Is there any limitation in the language standard, or does it depend on the compiler/platform? For example, I can write: ```cpp int a = 5; int* p1 = &a; int** p2 = &p1; int*** p3 = &p2; int**** p4 = &p3; // and so on... ``` But what if I try to create a pointer with 100 levels of indirection? Will it compile? And if so, how will it work at runtime? It seems to me that in practice no one uses more than 2-3 levels, but I want to understand the formal limits. I'm also interested in whether there is a difference between C and C++ in this regard? I've heard that in C the limit...