CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2008
    Posts
    6

    Unhappy global map<> not expanding

    I've posted this in 3 other forums over the last week but haven't recieved any answers. Basically, I need to know why a global map doesn't expand when added to.

    Here's my previous post at experts-exchange, which is the most thorough:
    http://www.experts-exchange.com/Prog..._23835913.html

    Here it is at
    http://www.c-sharpcorner.com/Forums/...ThreadID=49016

    assuming most people wont have EE memberships

    And again at
    http://www.byond.com/developer/forum/?id=669122

    Well, this is my first post at codeguru, for whatever that's worth.

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: global map<> not expanding

    Code:
    listOfPlayers[num] = Player1;
    1) If there is already a "num" key in the map, this line of code just overwrites the original "num" key, i.e. nothing is added.

    2) You shoud show us a main() program that attempts to add to this map. We don't know if something does or doesn't work unless we see something that actually drives the code that doesn't work.

    3)
    Code:
     extern "C" bool R_CONTROLLER_API CreatePlayer(int num)
    Not good.

    A "bool" is a C++ type, not a 'C' type -- you cannot predetermine that a "bool" will be the same size on different compilers or versions of the compiler, or is a consistent size given certain compiler options. Use 'C' types that are the same size (Windows types such as LONG, for example).

    Regards,

    Paul McKenzie

  3. #3
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: global map<> not expanding

    The most likely reason a global variable wouldn't be changed when you expect it to be is if a local variable with the same name is shadowing it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured