CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 24

Threaded View

  1. #13
    Join Date
    Mar 2008
    Posts
    38

    Re: how to implement c++ table lookup?

    Quote Originally Posted by Lindley View Post
    [][] should word automatically with a map< int, map<int,int> >.....

    Although, there is one thing to be careful of. Using [] on a map *will* add that key to the map if it isn't there already (with a default-constructed value, in this case 0).

    If you want to be able to test whether or not a pair is in the map yet, you'll have to use find() instead.
    thanks for the warning.

    my code looks like this:
    Code:
     
    int GetValueAt(int x,int y)
    {
    return table[x][y]; 
    }
    If I try some random x and y where table[x][y] doesn't exist, it will make one? And then return 0 ?
    Last edited by sdcode; May 29th, 2009 at 02:19 PM.

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