Я новичок в с ++.Я пытаюсь добавить объект дракона в cpp, но получаю ошибку при добавлении объекта
#include "dragon.h"
using std::cin;
#include <map>
using std::map;
#include <list>
#include <string>
#include <iostream>
using namespace std;
using std::list;
typedef map<string,list<Dragon> >::iterator iter;
typedef map<const string,list<Dragon> >::value_type dmaptype;
void display(map<string,list<Dragon> > dmap1,iter dmapiter1);
int main( )
{
map<string,list<Dragon> >dmap;
iter dmapiter;
bool again = true;
string name;
double length;
string colour;
string location;
while( again )
{
// get the details for the dragon
cout << "\nEnter dragon name >> ";
getline( cin, name );
cout << "\nEnter dragon length >> ";
cin >> length;
cin.get( );
cout << "\nEnter dragon colour >> ";
getline( cin, colour );
// now get the location
cout << "\nEnter location >> ";
getline( cin, location );
dmapiter=dmap.find(location);
Dragon * ptr ;
ptr=new Dragon(name,length,colour);
if(dmapiter==dmap.end())
{
list<Dragon*> dlist;
dlist.push_back(ptr);
dmap.insert(dmaptype(location, dlist));
}
else
{
dmapiter->second.push_back(*ptr);
}
char choice;
cout << "\nEnter another dragon and location [ y / n ] ? ";
cin >> choice;
cin.get( );
if( choice != 'y' && choice != 'Y' )
{
again = false;
}
}
display(dmap,dmapiter);
cout << endl;
return 0;
}
, когда я компилирую программу, получаю сообщение об ошибке:и ошибка:
error: no matching function for call to ‘std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::list<Dragon, std::allocator<Dragon> > >::pair(std::string&, std::list<Dragon*, std::allocator<Dragon*> >&)’
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_pair.h:83: note: candidates are: std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _T1 = const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _T2 = std::list<Dragon, std::allocator<Dragon> >]
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_pair.h:79: note: std::pair<_T1, _T2>::pair() [with _T1 = const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _T2 = std::list<Dragon, std::allocator<Dragon> >]
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_pair.h:68: note: std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::list<Dragon, std::allocator<Dragon> > >::pair(const std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::list<Dragon, std::allocator<Dragon> > >&)
Любая помощь будет оценена ...
Спасибо