# 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
Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.
Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!
On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.
Top comments (0)