# 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
Join the Runner H "AI Agent Prompting" Challenge: $10,000 in Prizes for 20 Winners!
Runner H is the AI agent you can delegate all your boring and repetitive tasks to - an autonomous agent that can use any tools you give it and complete full tasks from a single prompt.
Top comments (0)