Thread: comprehending arrays.

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> Except now it seems like the amount is twice as long.
    The amount doesn't always matter, often one little typo will cause lots of errors. For example, the missing std:: caused all 9 of your earlier errors.

    Your new problem is your calls to insert aren't correct. There is a simple solution:
    Code:
    menu[str] = 1.95;
    If you want to actually use insert, then you need to make a pair object that holds the two values (because a map actually holds key/value pairs). One way to do that is to use make_pair like this:
    Code:
    menu.insert(std::make_pair(str, 1.95));
    However, I'd suggest sticking with the notation in the first example I gave for now, since it is slightly more intuitive.

  2. #17
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Location
    CA, USA
    Posts
    466
    :P

    Uh, you've overstepped your array bounds by one. Simple error I noticed from the start.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  2. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  3. My Arrays!!!, My Arrays!!! Help!?
    By llcool_d2006 in forum C++ Programming
    Replies: 1
    Last Post: 12-10-2006, 12:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM