0

Why the output is 26 not 23? Why did the value of (*p2) also change to 13?

#include <iostream> using namespace std; int main() { int a=10; int b=13; int *p1=&a; int *p2=&a; *p1=b; cout<<(*p1)+(*p2); return 0; }

27th Jul 2018, 8:09 AM
Yelyzaveta Al-Dara
1 Antwort
+ 1
its like having two same copies of a box. If you change the contents, it will in the copy (technically its not a copy but hey, this is an analogy).
27th Jul 2018, 6:05 PM
Bebida Roja
Bebida Roja - avatar