+ 2

Could someone tell.....

what is the diffrence between those two codes: ♦first: int var=5; cout<<&var; ♦second: int var=5; int*p; p=&var; cout<<p; is it always necessary to declare a pointer in order to access the adress of var? can we access it without using any pointers?? as we did in the 1st one?? what is the difference?

25th Dec 2017, 7:08 PM
RiGeL
RiGeL - avatar
4 Respostas
+ 4
there is no difference in the output but first :- there is no usage of memory. second:- there is usage of memory bcoz it will store the (var) and also store *p which makes more memory compare to first one
25th Dec 2017, 7:48 PM
Yesh Jadav
Yesh Jadav - avatar
+ 2
your welcome anytime
25th Dec 2017, 8:12 PM
Yesh Jadav
Yesh Jadav - avatar
+ 1
@Yesh thank you
25th Dec 2017, 8:11 PM
RiGeL
RiGeL - avatar
+ 1
thanx
18th Mar 2018, 6:00 PM
Said Mahi
Said Mahi - avatar