summaryrefslogtreecommitdiff
path: root/c,cc/copy_struct.cc
blob: cb23b0939d0d371b8f4fd7c1d3a8c40404adc14f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <vector>

using namespace std;

struct C {
  vector<int> i;
};

struct B {
  C c;
};

struct A {
  B b;
};

int
main(void)
{
  A a;
  B b;
  C c;
 
  c.i.push_back(23);
  b.c = c;
  a.b = b;

  cout << a.b.c.i[0] << endl;

  A x(a);
  cout << x.b.c.i[0] << endl;

  return 0;
}