comprehending arrays.

This is a discussion on comprehending arrays. within the C++ Programming forums, part of the General Programming Boards category; >> Except now it seems like the amount is twice as long. The amount doesn't always matter, often one little ...

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    >> 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
    Posts
    311
    :P

    Uh, you've overstepped your array bounds by one. Simple error I noticed from the start.
    GCC on Fedora Core 10

Page 2 of 2 FirstFirst 12
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, 03:24 PM
  2. Replies: 16
    Last Post: 01-01-2008, 03:07 PM
  3. My Arrays!!!, My Arrays!!! Help!?
    By llcool_d2006 in forum C++ Programming
    Replies: 1
    Last Post: 12-10-2006, 11:07 AM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 09:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 08:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21