> But, with my list as an example, I have 68 items in the list. So > I have to set each line in the list like this (or in a switch statement): > if (dwGetItemDataValue == 1) > csNew = Get1(); > else if (dwGetItemDataValue == 2) > csNew = Get2(); > else if (dwGetItemDataValue == 3) > csNew = Get3(); > etc. etc. all the way to 68, very tedious... and think of how I > have to rewrite the numbering if I insert a new list item in the > middle of the list. > > And it even gets more complicated because the number of items in > my list varies. Sometimes it might be 68 items long, and > sometimes it might be 22 (or other numbers) items long. So > sometimes the 60th item in the list would use Get60() and at > other times the 40th item in the list would use GetXX() (some > other 'Get' function). > > It just would make a lot more sense to assign a pointer to > function or a pointer to member to each list item.
In my contrived second sample I used a dynamic array, which meets your varying list size needs, and the index obtained by adding a pointer there was used as the dwGetItemDataValue... so calling the function is as easy as funcPtr = my_dynamic_list.get_item(dwGetItemDataValue); (get function name faked for imaginary container / map) Voila - one pointer ready to use. Why can't that be used to simplify getting the right pointer to use instead of the chain of if/else? -- Jason Teagle [EMAIL PROTECTED] _______________________________________________ msvc mailing list [EMAIL PROTECTED] See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.
