First we make to objects num1 and num2, and than input object num1, and than use assignment operator between num2 and num1, and than cout the object num2. Than you can watch that the value of object num1 assign to object num2. So, you can read code below to understand the use of assignment operator.
Code:
#include <iostream>
using namespace std;
int main() {
int num1,num2;
cout<<"Enter first number : ";
cin>>num1;
num2=num1;
cout<<"Num2 : "<<num2;
}
Output:
Enter first number : 4
Num2 : 4
So, you can see the assignment of the value of object one of object two.
0 Comments