Error calling a member function using a passed vector of class pointers

So I'm passing a vector of class pointers to a function, but I'm getting an error.
This may be an obvious error to experienced programmers...

In my main function, I've declared my vector of class pointers like so:
 
vector <MutantChameleonDie*> diceArray;


And then later I call this:

 
display(diceArray);


Which brings the program to this:

1
2
3
4
5
void display(vector<MutantChameleonDie*> array)
{
    for (int position = 0; position < 5; position++)
        cout << "Rolling dice number " << (position+1) << ": " << array[position].roll();
}


roll() is a class member function, BUT I get an error message that says this:

request for member 'roll' in 'array.std::vector<_Tp, _Alloc>::operator[] [with _Tp = MutantChameleonDie*, _Alloc = std::allocator<MutantChameleonDie*>](((unsigned int)position))', which is of non-class type 'MutantChameleonDie*'|

And just for reference, this is where the function is declared in my class:

1
2
3
4
5
6
7
8
9
10
class MutantChameleonDie {
public:
//constructor
    MutantChameleonDie(int numSides, char *initialColor, int faceValue);

//copy constructor
    MutantChameleonDie(MutantChameleonDie &existingDie);

//roll the die, return the resulting value
    int roll();


I think I'm just getting my syntax wrong since this seems to be a pretty simple operation. I've googled a fair amount but am unable to find a situation that matches mine. Please help?

When referencing members from pointers to objects, use ->, not .
HELIOS!!!

YOU'RE AWESOME!

I KNEW it was a simple thing. THat makes perfect sense. I've read a lot on pointers. How could I forget that?

Sheesh.
Topic archived. No new replies allowed.