Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication4.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <map>
- #include <string>
- #include <iostream>
- #include <iterator>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- map <int, string> my_students_list; //value_type
- int stud_num=1234;
- string stud_name="Petrenko";
- my_students_list.insert(make_pair(stud_num,stud_name));
- my_students_list.insert(map<int, string>::value_type(2345,"Antonov"));
- cout << my_students_list[1234] << endl;
- if (my_students_list.find(123)!=my_students_list.end())
- cout << my_students_list[123] << endl;
- else
- cout << "Student not found" << endl;
- auto ret = my_students_list.insert(map<int, string>::value_type(234,"Bogach"));
- if (!ret.second){
- cout << "Element already exists." << endl;
- }
- else{
- cout << "Element inserted:" << endl;
- cout << my_students_list[234] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement