Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > C/C++ программирование > Общие вопросы C/C++
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 13.09.2010, 21:45   #1
Progsenya
Пользователь
 
Регистрация: 30.05.2010
Сообщений: 80
По умолчанию Insert в Multimap

Код:
#include<iostream>
#include<iterator>
#include<algorithm>
#include<vector>
#include<time.h>
#include<fstream>
#include<deque>
#include<string>
#include<typeinfo>
#include<string.h>
#include<conio.h>
#include<iomanip>
#include<functional>
#include<map>
#include<string>
#include<set>
using namespace std;
class Person
{
private:
	string LastName;
	string FirstName;
	int phone;
public:
	
	Person():LastName(" "),FirstName(" "),phone(0)
	{
	}
	Person(string ln,string fn,int ph)
	{
		LastName=ln;
		FirstName=fn;
		phone=ph;
	}


};


void main()
{
	/*Person p("Maks","Vorobev",9583301);*/
	 pair<char,Person> MyBoock;
	 multimap<char,Person> Nboock;
	 multimap<char,Person>::iterator it;
	 Nboock.insert(MyBoock ('A',"Artem","Kalugniy",345678));
	




}
кто подскажет плиз что делаю не так
Progsenya вне форума Ответить с цитированием
Старый 14.09.2010, 02:10   #2
pproger
C++ hater
СтарожилДжуниор
 
Аватар для pproger
 
Регистрация: 19.07.2009
Сообщений: 3,333
По умолчанию

Код:
#include <iostream>
#include <map>
#include <string>

using namespace std;

//--------------------------------------------------------------------------------------
class Person {
public:
	Person()
		: LastName(" "), FirstName(" "), phone(0)
	{}

	Person(string ln, string fn, int ph)
		: LastName(ln), FirstName(fn), phone(ph)
	{}

private:
	string LastName;
	string FirstName;
	int phone;

	friend ostream &operator<<(ostream &o, const Person &p);
};

//--------------------------------------------------------------------------------------
ostream &operator<<(ostream &o, const Person &p)
{
	o << "FirstName: " << p.FirstName << endl;
	o << "LastName: " << p.LastName << endl;
	o << "Phone: " << p.phone << endl;
	return o;
}

int main()
{
	 multimap<char,Person> Nboock;

	 Nboock.insert(make_pair('A', Person("Artem1","Kalugniy1",345678)));
	 Nboock.insert(make_pair('B', Person("Artem2","Kalugniy2",345678)));
	 Nboock.insert(make_pair('C', Person("Artem3","Kalugniy3",345679)));

	 for (multimap<char,Person>::iterator It = Nboock.begin(); It != Nboock.end(); ++It)
		 cout << It->second << endl;

	 return 0;
}
I invented the term Object-Oriented, and I can tell you I did not have C++ in mind. (c)Alan Kay

My other car is cdr.

Q: Whats the object-oriented way to become wealthy?
A: Inheritance
pproger вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Функция INSERT() fygas1991 PHP 2 27.12.2009 22:52
vector, list или multimap. Помогите, пожалуйста, класс выбрать! Pahan Общие вопросы C/C++ 0 13.12.2009 12:54
Multimap Chartvit Общие вопросы C/C++ 6 21.11.2009 21:46
запись содержимого STL::multimap в файл с сохранением пар nimizida Общие вопросы C/C++ 4 29.09.2009 17:03
Insert - ? Evgenii БД в Delphi 2 06.07.2009 02:24