Indexing and reading individual classes

I REALLY need help with this, I've been slaving over it for a while and simply cannot grasp it. Essentially what I'm trying to do is this (forgive me, I'm terrible at explanations):

1. Be able to define a class, such as this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Item
{
private:
   string name;
   int id, type;
public:
   Person(string _name, int _id, int _type)
   {
      name = _name;
      id = _id;
      type = _type;
   }
};

...

Item cup = new Item("Cup", 1, 2);


2. Create an array of class "references" (id variables from the class?), serving as an inventory

3. Be able to call the information from the specifically-named class without having to reference it as such (a more general reference, like for all of the objects of a class)

 
Display the contents of current cell of aforementioned array without calling the individual objects (*.name, as opposed to individualObject.name X 3 billion)


I apologize in advance for my horrible explaining, please ask if there is something you need specified more, but help would be greatly appreciated.
Last edited on
1
2
3
4
5
6
7
8
9
Item *MyItemArray = new Item[userInput];

for(int i=0; i < userInput; i++)
{
    MyItemArray[i].setsomething(i);
}
//code

delete[] MyItemArray;
Last edited on
Topic archived. No new replies allowed.