Hi,
I have some pointer to a map, because I want to be able to dynamically allocate this map at a certain time, however, I can't seem to assign any values or keys to the map. Here's some mockup code (which gives me the same error)
Code:
#include<map>
#include<stdio.h>
using namespace std;
int main()
{
map<int, char*> * the_map;
the_map = new map<int, char*>();
the_map[0] = "zero";
char * val = the_map[0];
printf("val: %s.\n", val);
return 0;
}
The error is:
Code:
stupid.cpp: In function ‘int main()’:
stupid.cpp:10: error: no match for ‘operator=’ in ‘* the_map = "zero"’
/usr/include/c++/4.2.1/bits/stl_map.h:226: note: candidates are: std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(const std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = int, _Tp = char*, _Compare = std::less<int>, _Alloc = std::allocator<std::pair<const int, char*> >]
stupid.cpp:11: error: cannot convert ‘std::map<int, char*, std::less<int>, std::allocator<std::pair<const int, char*> > >’ to ‘char*’ in initialization
What have I missed?
Thank you so much!