How do I call a pointer to a member function?

doing it like this gives the error 'term does not evaluate to a function taking 1 argument'

ent->GetInputs()[i]->function(i);

where function is of the type

void (__thiscall CBaseEntity::* inputfunc_t)(inputdata_t *data)

and ent is of type CBaseEntity*

Recommended Answers

All 2 Replies

If ent is a single pointer to a CBaseEntity then you can do

ent->frunction();

If ent is an array of CBaseEntity objects then you can do

ent[i]->function();

If you are acessing a members of the CBaseEntity object and calling a function that exist for that member than it would be

ent[i]->member->function();
// or
ent[i]->menber.function(); // if member is not a pointer

lastly if you are calling a function that returns a object and calling a function of that returned object

ent[i]->function1()->function2();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.