What is the output of below C++ program?
int a = 10;
int &b = a;
garbage value or it may crash at run time.
compile time error at int &b = a; invalid syntax.
& is reference operator in c++. It is used as alias name of other variables. Here in our program b is alias name of a, if we change b value it will affect value of a also. So since we are incrementing b to 11, it will automatically increment a value also as b is alias of a.
Back To Top