+ 2

Can anyone please explain the output?

char a = 'a', b = 'b' ; char *p = &a; char *&r = p; //This statement is new for me r = &b; cout<<*p;

25th Jan 2018, 1:00 PM
Harshit Gupta
Harshit Gupta - avatar
5 Respostas
+ 5
Hello, @Harshit I have a code for you to understand it. It is with comments explained in it. https://code.sololearn.com/cpYPAKefbNP8/#cpp
25th Jan 2018, 1:17 PM
Akash Pal
Akash Pal - avatar
+ 3
https://www.sololearn.com/Discuss/1028274/explaination-needed-for-this-code @Harshit See this it is answered.
25th Jan 2018, 2:18 PM
Akash Pal
Akash Pal - avatar
+ 2
@Harshit it is giving output :- ba$ ( when I used cout << p; I don't know the reason. I am too new to c++. But I am going to ask this in a post or on discord server of the sololearn.
25th Jan 2018, 1:38 PM
Akash Pal
Akash Pal - avatar
+ 1
When I ask for cout<<p it shows 'ba' , reason?
25th Jan 2018, 1:26 PM
Harshit Gupta
Harshit Gupta - avatar
+ 1
Hey pal, thanks so much trying to help me. But this one, I already knew that it shows the address of p but what I don't get is why does it show 'ba'? why 'a' after 'b' ?
25th Jan 2018, 2:23 PM
Harshit Gupta
Harshit Gupta - avatar