# include <iostream>
usingnamespacestd;intmain(){// defining number 1intnum1=11;// defining number 2intnum2=num1;// redefining num1num1=22;// print out the num1 and num2cout<<"num1 = "<<num1<<endl;cout<<"num2 = "<<num2<<endl;}
Result : value will be different in both num1 and num2
Code with Pointers
# include <iostream>
usingnamespacestd;intmain(){// defining num1 using pointerint*num1=newint(11);// defining num2 using pointerint*num2=num1;// print out the num1 and num2cout<<"num1 = "<<*num1<<endl;cout<<"num2 = "<<*num2<<endl;}
Result : value will be same in both num1 and num2
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)