Tell output and reason!!!!For this code: | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Tell output and reason!!!!For this code:

#include <iostream> using namespace std; int main() { char a='a',b='b'; char *p=&a; char *&r=p; r=&b; cout<<p; return 0; }

23rd Mar 2017, 9:52 AM
Gaurav Kaushik
Gaurav Kaushik - avatar
1 Answer
+ 5
It will show the memory address of the character variable b as p is a character pointer and at first it is pointing to variable a, then reference of p is created namely 'r' (reference is just a substitute name for a variable), and then p is pointing to memory location of b through this 'r=&b'. Hope this helps.
23rd Mar 2017, 1:30 PM
Rishabh Agrawal
Rishabh Agrawal - avatar