O'Reilly logo

Software Engineering and Computer Games by Rudy Rucker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

22.16. Resizable arrays

Suppose you want to have an array that holds, say, cCritter objects. There are really three options: maintain your own C-style array, use an array template from the ANSI C++ STL Standard Template Library, or use the Microsoft CArray template.

To maintain an array yourself means using a declaration like cCritter *_critter or cCritter _critter[]. (Note that C regards these two declarations as equivalent; in C an array is simply a pointer.) If you do this, you would also need an int _critter_count variable to keep track of the current number of points stored. And you’d either have to preallocate _critter to some generously large size (and worry about eventually writing off the end), or you’d have to keep reallocating the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required