I want to get this out of the way. It may sound stupid, but I always end up doing it wrong and causing all sorts of problems.
How do I make an array with an unlimited amount of elements.
Thanks
I want to get this out of the way. It may sound stupid, but I always end up doing it wrong and causing all sorts of problems.
How do I make an array with an unlimited amount of elements.
Thanks
-Save the whales. Collect the whole set.
You can't. To create a static or even dynamic array you have to specify the size.
If you want to have a container that can hold an "unlimited" (which of course is not possible because you can always run out of memory ) number of elements, you can use a linked list or other such data structure.
Use one of the provided STL containers, probably a vector would be best for you. For example...
Code:#include <vector> ... vector<int> v1; // Create a vector to hold ints ... // Now just keep pushing ints onto the vector to your heart's content. // It will keep growing and growing... v1.push_back(1); v1.push_back(14); ... v1.push_back(-6);
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
That's nice, but what's the liscence info on that.Originally posted by hk_mp5kpdw
Use one of the provided STL containers, probably a vector would be best for you. For example...
Code:#include <vector> ... vector<int> v1; // Create a vector to hold ints ... // Now just keep pushing ints onto the vector to your heart's content. // It will keep growing and growing... v1.push_back(1); v1.push_back(14); ... v1.push_back(-6);
Do big game developers use it?
-Save the whales. Collect the whole set.
It's part of the STL.