From 626c2cd921e7442c20ac1be7be0b9ecb44d00c95 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sat, 6 Sep 2014 22:32:49 +0100 Subject: cc examples --- c,cc/struct_init.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 c,cc/struct_init.cc (limited to 'c,cc/struct_init.cc') 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 +#include +#include + +using namespace std; + +struct POD { + POD() { a = 2; } + POD(int x) { a = x; } + int a; +}; + +int +main(void) +{ + vector > a; + pair p = make_pair('a','b'); + a.push_back(p); + vector > b(a); + cout << b[0].first << endl; + b[0].first = 'c'; + cout << b[0].first << endl; + + vector w; + POD x; x.a=3; + w.push_back(x); + POD y(x); + vector q(w); + cout << q[0].a << endl; + + return 0; +} + -- cgit v1.2.3