Originally Posted by
skynet0928
Essentially, just an array of objects. I'm certain that bitstring->data[x] would tell me what is in data array at the x position and bitstring->selected would give me a true or false depending on what I set it on but I don't know which person I am accessing or if I even have more than one person.
Not quite (but almost). The variable 'bitstring' is a pointer to a contiguous memory block of type 'person'.
Think of 'bitstring' like this:
[person0][person1][person2] ... [person85]
And each person is a struct or class, which you can access in the memory block with it's index number (to the right of 'person' in the example).
So if you were to write:
Code:
int personInfo = bitstring->data[number];
The computer won't know how to get to the 'data' member, because 'bitstring' isn't a struct or class, it's just a pointer to some memory you've allocated with keyword new. You need to reference the specific 'person' in 'bitstring' with an index:
Code:
// Assign 'pPerson' (a pointer to type person), with the address at the index 'number'
// in the 'bitstring' memory block:
person* pPerson = bitstring[number];
// Now 'pPerson' is a pointer to the 'person' type you have stored at index 'number'.
// Now you could access the 'person' type:
if (true == pPerson->selected)
{
pPerson->data[10] += 1; // This change is reflected in: bitstring[number]->data[10]
}
// To access the data directly, without declaring the variable 'pPerson', you do:
bitstring[index_of_person]->member_of_person;
I hope this was clear. If not just let me know, pointers can be confusing for everyone!