Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <functional>
- struct teste {
- int n;
- };
- int main() {
- std::map<char, teste> m;
- teste tst;
- tst.n = 5;
- m.insert(std::make_pair('c', tst));
- std::map<char, teste>::iterator it1 = m.find('c');
- if (it1 != m.end()) {
- teste tst1 = it1->second;
- std::cout << tst1.n << std::endl;
- }
- std::map<char, teste>::iterator it2 = m.find('c');
- if (it2 != m.end()) {
- teste tst2 = it2->second;
- tst2.n = 42;
- it2->second = tst2;
- }
- std::map<char, teste>::iterator it3 = m.find('c');
- if (it3 != m.end()) {
- teste tst3 = it3->second;
- std::cout << tst3.n << std::endl;
- }
- system("pause");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement