0

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*

Edited by mike_2000_17: Fixed formatting

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by NathanOliver
0

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();
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.