#include<iostream>using namespace std; int main(){ //part 1 //not able to compile int *b1 = 0; const int *& n1 = b1; //part 2 //able to compile int a2 = 0; int *b2 = &a2; const int & n2 = *b2; cout << n2 << endl; // n = 0 *b2 = 3; cout << n2 << endl; // n = 3 return 0;}
Standard input is empty
prog.cpp: In function 'int main()': prog.cpp:8:23: error: invalid initialization of non-const reference of type 'const int*&' from an rvalue of type 'const int*' const int *& n1 = b1; ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!