Is it legal to have a pointer of a reference in C++?
For example:
int &ref = array[idx];
func(&ref);
One reason I can think of why you might want to do this if func() already exists in a library which you can't change.
It is not. The address of a reference can be taken, but "pointer to a reference of T" is not a valid type. What you are doing here is taking a pointer to the object itself, since a reference to an object simply creates another name by which you can access that same object.
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