-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
40 lines (36 loc) · 782 Bytes
/
test.cpp
File metadata and controls
40 lines (36 loc) · 782 Bytes
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
37
38
39
40
#include <iostream>
#include <string>
#include <memory>
#include <map>
#include <algorithm>
#include <exception>
#include <vector>
using std::cout;
using std::endl;
using std::shared_ptr;
using std::string;
using std::map;
using std::vector;
class Foo {
public:
int foo;
explicit Foo(int foo_);
string foo_str = "foo";
string hey();
};
Foo::Foo(int foo_):foo(foo_) { }
string Foo::hey() {
return foo_str;
}
int main(int argc, char const *argv[]) {
vector<map<string, int>> scopes;
map<string, int> m;
scopes.push_back(m);
auto res = scopes[scopes.size() - 1];
res["hello"] = 10;
scopes.emplace_back(res);
auto res2 = scopes[scopes.size() - 1];
cout << res["hello"] << endl;
cout << res2["hello"] << endl;
return 0;
}