
pointer to a reference in C++

#include <iostream>
using namespace std;
void foo1(int& x)
{
int* p = &x;
*p = 123;
}
void foo2(int* x)
{
int** p = &x;
**p = 345;
}
int main(int argc, char* argv[])
{
int abc = 0;
foo1(abc);
cout << abc << "\n";
abc = 0;
foo2(&abc);
cout << abc << "\n";
return 0;
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.