diff options
author | Patrick Simianer <p@simianer.de> | 2014-09-06 22:32:49 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-09-06 22:32:49 +0100 |
commit | 626c2cd921e7442c20ac1be7be0b9ecb44d00c95 (patch) | |
tree | d9bb1d4c670ffc3e6094202dc2d5764040c4c1ff /c,cc/struct_init.cc | |
parent | 01215a3f542df6692ef12b4e4b5fed551d065545 (diff) |
cc examples
Diffstat (limited to 'c,cc/struct_init.cc')
-rw-r--r-- | c,cc/struct_init.cc | 33 |
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; +} + |