Array to member functions help

Hey forum goers,

the problem I'm having is that I've made a pointer array to make some monsters then later I'm trying to call a memeber function from a header file of a class,

I'm trying to make 10 monsters using this bit of code

Monsters* myMonsterList[maxarray] (max array is const int of 30)

for(int i=0; i < maxarray; i++)
{
if(i < 10)
{
myMonsterLift[i] = new Monster;
}
else
{
myMonsterList[i] = NULL;
}
}


then a bit later on I'm trying to call, using this above array, a member function in my header file containing class Monster
the function is

void moveMentMons()
{
<here is an if statement that determines random movement>
}

so far I have, to call the function

for(int i=0; i < 10; i++)
{
myMonsterList[i].moveMentMons();
}

myMonsterList[i] (from the above code) is red underlined saying "expression must have a class type"

Thanks for anyhelp
Mike






myMonsterList[i] is a pointer to a Monster object. Try

myMonsterList[i]->moveMentMons();
Topic archived. No new replies allowed.