Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SP-STL-02.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <map>
- using namespace std;
- class Student {
- public:
- string FirstName;
- string LastName;
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- Student s1,s2;
- s1.FirstName="Ivan";
- s1.LastName="Ivanov";
- s2.FirstName="Petro";
- s2.LastName="Petrov";
- map<int,Student> students_book;
- map<int,Student>::iterator student;
- students_book[124]=s1;
- students_book[125]=s2;
- /*cout << students_book[123].FirstName << " "<< students_book[123].LastName<<endl;
- cout << students_book[124].FirstName << " "<< students_book[124].LastName<<endl;*/
- student = students_book.lower_bound(124);
- if (student == students_book.end())
- cout << "Not found" << endl;
- else
- {
- cout << "Found " << student->first <<" "<<student->second.LastName << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement