summaryrefslogtreecommitdiff
path: root/c,cc/copy_struct.cc
diff options
context:
space:
mode:
Diffstat (limited to 'c,cc/copy_struct.cc')
-rw-r--r--c,cc/copy_struct.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/c,cc/copy_struct.cc b/c,cc/copy_struct.cc
new file mode 100644
index 0000000..cb23b09
--- /dev/null
+++ b/c,cc/copy_struct.cc
@@ -0,0 +1,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;
+}
+