The definition:
CItem **m_inventory;[/source]basically declares a variable m_inventory to be a pointer to a pointer. You can use that to declare an array of pointers to instances of CItem.You could have equally done this (example 1):[source]CItem *m_inventory[50];[/source]which declares an array of pointers to instances of class CItem.This locks you into having an array of 50 items (for example). Where as the original example (example 2) eg:[source]int m_maxItems = 30;CItem **m_inventory;m_inventory = new CItem*[m_maxItems];
allows you to dynamically allocate as many items you wish for a single entity. Ie if some Entities cannot carry any objects, there's no need to allocate memory for it (a saving) whereas with example 1, you will always have allocated 50 pointers for every Entity whether you need less or more.
I dont mean this nastily, but i think you should have a read of some books on object orientated programming and C++. They can explain more than i can write here.
Edited by - shamen on July 18, 2000 10:20:59 AM