10.4. Arrays of critters: the cBiota class

One of the key members of the cGame class is a cBiota *_pbiota field. The cBiota class is a collection class that holds an array of pointers to cCritter objects. The cBiota object is based on an MFC array template, with a few special methods added. We encapsulate these methods into the cBiota rather than having them in cGame as part of the OOD strategy of not giving any one class too many responsibilities.

Some readers may be wondering why we have to use a collection of cCritter* pointers. Beginning programmers have a fear of pointers and their burdensome requirements of being initialized with new and removed with delete. Why not just a collection of cCritter objects? Once again, this is because we ...

Get Software Engineering and Computer Games now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.