It just occurred to me That I don't know how to initialize a pointer to pointer from a non pointer value with one statement in C++:
int a = 1;
int** ppa = &&a; //Does not compile
int** ppa = &(&a); //Does not compile
int* pa = &a; //Works but is a
int** ppa = &pa; //Two step solution
Am I missing something, is the two statement the one and only way to do it?
if you want a pointer to a pointer, the pointer that you want to point to must be located somewhere in memory, so I think there cannot be a "one step solution" because you need a pointer variable that you can point to.
(Note: This sentence is not meant to be a linguistic trial to use "point" as often as possible in one sentence :-))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With