Sign in to follow this  
Rubiks14

question about multi arrays

Recommended Posts

stylin    758
Quote:
Original post by Rubiks14
how do you make a multidimentional array that has...lets say a column of strings and a column of integers?

thanks, Rubiks14

Just how do you want to interact with this array? A std::map<...> might be what you're looking for, but I'd need more details to help more.

Share this post


Link to post
Share on other sites
Rubiks14    143
ok i'm wanting to set up a multidimensional array that has in column 1 what the item is and in column 2 what the price of that item is (i'm just making kind of like a market for rpg just for some practice)

P.S. i'm also just wanting to use something that is in the area of what all i know. i just got through reading chap 3 in Beginning C++ Game Programming so basically the extint of my knowledge is multidimensional arrays

Share this post


Link to post
Share on other sites
Zahlman    1682
It's quite simple, really. You make a thing that represents the pairing of a name and number, giving that the name "rpg_item" (or some other name that makes better sense to you; we can't see the rest of your project, after all). Now you can just make a simple 1-dimensional array of those. That makes things much neater, by strengthening the association between any given item name and its cost value.

Then, since arrays are evil, we make use of the standard library container std::vector.

If you "aren't that far in your book" yet, there's a good chance that your book is all out of order, and/or missing important topics (or covering useless or even potentially harmful ones). Which exactly are you using?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this