Google Answers Logo
View Question
 
Q: C++ STL map question - why does this not compile? ( No Answer,   0 Comments )
Question  
Subject: C++ STL map question - why does this not compile?
Category: Computers > Programming
Asked by: mtb_man-ga
List Price: $2.00
Posted: 11 Aug 2004 19:07 PDT
Expires: 12 Aug 2004 06:58 PDT
Question ID: 386753
why does this fail to compile at the m_map.insert() call?  Error
message follows code fragment.

#include <iostream>
#include <map>

using namespace std; 	//introduces namespace std
int foo( void )
{
	map <int, int *> m_map;
	int i = 10;
	m_map.insert(1,&i);
}
------------------------
Error   : function call 'insert(int, int *)' does not match
'std::map<int, int *, std::less<int>, std::allocator<std::pair<const
int, int *>>>::insert(const std::pair<const int, int *> &)'
'std::map<int, int *, std::less<int>, std::allocator<std::pair<const
int, int *>>>::insert(std::__tree<std::pair<const int, int *>,
std::map<int, int *, std::less<int>, std::allocator<std::pair<const
int, int *>>>::value_compare, std::allocator<std::pair<const int, int
*>>>::iterator, const std::pair<const int, int *> &)'
'std::map<int, int *, std::less<int>, std::allocator<std::pair<const
int, int *>>>::insert<...>(T1_0, T1_0)'
hello.cpp line 11    m_map.insert(1,&i);
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy