Container verses array

I am trying to program my first app with the help of dragonfiresdk. I don't have much experience with arrays and want to continue using containers for this. Is there any reason I would want to learn to use container classes with my game/app instead?
closed account (zb0S216C)
Arrays are very primitive and you're required to provide an API for an array in order to use them effectively. However, containers have an API designed to handle the underlying memory effectively and efficiently. Depending on the type of container you use, containers can support addition and removal of elements at any time, whereas arrays do not support this.

Arrays are useful if you want to collapse multiple objects of the same type into 1 line:

1
2
3
4
5
6
7
// Instead of:
int a1_;
int a2_;
int a3_;

// ...you'd write:
int a_[3] = {0};

Containers are safer than arrays, but at the expense of memory usage.

Overall, then, I would use containers; safe, somewhat flexible, cross-platform, and support iteration. A no-brainer, really.

Wazzak
Last edited on
That makes sense. Thanks for the explanation.
hey freta, I'm looking at trying my hand at making an iphone app. How has dragonfire worked out for you? Seeing that I don't want to get a mac, this looked like a decent solution, I'd love your feedback thanks
You can write software for apple without having to learn objective C?! :O

Do these applications perform any differently in term of speed, memory, etc.?

Hey guys, yeah you can! dragonfiresdk has been a good option for me. It's nice writing code in c/c++ to make my app and the api is easy to understand. It's great for making 2d iphone games like angry birds. The apps I've made run great and don't run slower than apps made with a Mac.
Topic archived. No new replies allowed.