views:

75

answers:

2

I have data for countries which include Name, Population, Area etc for countries...

What is the best way to store them, I was thinking of static arrays in header files ...?

I am using c++ primarily for some game on iPhone

Should I consider other options like sqlite, plists, dictionaries ....?

+1  A: 

It depends. If the data is never going to change then static arrays in header files is probably a good enough solution. The problem is that if one day you do want to make a change to the data, you'll have to recompile your application, which might not be a concern for you. But it might also be a complete hassle, especially if you need to repeatedly try out different values for some of the data.

Personally I'd be tempted to store this data in an external file of some description. plists might be perfect for this, although if there's large amounts of unstructured data you might find them a bit heavyweight. I've often used simple plain text files for storing some types of data.

I suspect SQLite may be completely over the top, unless your data makes sense to be structured using a relational database, or needs to be changed by the app itself regularly.

Tom
A: 

Avoid data in code.

Dan Olson
Pithy, but not terribly useful to anyone.
Sixten Otto