summaryrefslogtreecommitdiff
path: root/c,cc/struct_init.cc
diff options
context:
space:
mode:
Diffstat (limited to 'c,cc/struct_init.cc')
-rw-r--r--c,cc/struct_init.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/c,cc/struct_init.cc b/c,cc/struct_init.cc
new file mode 100644
index 0000000..e54724a
--- /dev/null
+++ b/c,cc/struct_init.cc
@@ -0,0 +1,33 @@
+#include <iostream>
+#include <utility>
+#include <vector>
+
+using namespace std;
+
+struct POD {
+ POD() { a = 2; }
+ POD(int x) { a = x; }
+ int a;
+};
+
+int
+main(void)
+{
+ vector<pair<char,char> > a;
+ pair<char,char> p = make_pair('a','b');
+ a.push_back(p);
+ vector<pair<char, char> > b(a);
+ cout << b[0].first << endl;
+ b[0].first = 'c';
+ cout << b[0].first << endl;
+
+ vector<POD> w;
+ POD x; x.a=3;
+ w.push_back(x);
+ POD y(x);
+ vector<POD> q(w);
+ cout << q[0].a << endl;
+
+ return 0;
+}
+