location_copy
Example of = with objects.
24
 
1
#include <cmath>
2
#include <iostream>
3
using namespace std;
4
5
6
struct Location {
7
      int row;
8
      int col;
9
};
10
11
int main() {
12
   Location my_loc;
13
   my_loc.row = 2;
14
   my_loc.col = 1;
15
   
16
   Location your_loc = my_loc;
17
   // how are your_loc and my_loc related?
18
   
19
   // let's find out by changing your_loc then printing my_loc
20
   your_loc.row = 4;
21
   cout << my_loc.row << endl; // 2 or 4?
22
   
23
   cout << your_loc.row << endl;
24
}