error C2440: 'type cast' : cannot convert from 'std::_Vector_iterator<_Ty,_Alloc>' to 'DWORD'

前端 未结 2 1556
南笙
南笙 2021-01-23 09:20

I get the following error:

error C2440: \'type cast\' : cannot convert from \'std::_Vector_iterator<_Ty,_Alloc>\' to \'DWORD\'
        with
        [
              


        
2条回答
  •  醉梦人生
    2021-01-23 10:01

    Is your goal to just get rid of the error or to make the program correct? In the latter case you would have to tell us what you are actually trying to do.

    Since you didn't I have to guess. My guess is you want to convert an address of the first LPCSTRin the vector to DWORD. If your code worked in the previous version of VS, this is the more probable scenario. If I'm right try this:

    *(DWORD*)(offset+0x571) = (DWORD)(&factions.front());
    

    or this:

    *(DWORD*)(offset+0x571) = (DWORD)(&*factions.begin());
    

    or this:

    *(DWORD*)(offset+0x571) = (DWORD)(&factions[0]);
    

    If you want to convert the LPCSTR stored at the front of your vector to DWORD do this:

    *(DWORD*)(offset+0x571) = (DWORD)factions.front();
    

    or this:

    *(DWORD*)(offset+0x571) = (DWORD)(*factions.begin());
    

    or this:

    *(DWORD*)(offset+0x571) = (DWORD)(factions[0]);
    

提交回复
热议问题