c++ - Pointer passing to function header -
i have problem regarding pointers.
i have function following header:
addactor (nxuphysicscollection &c, nxactor &a, const char *userproperties=0, const char *actorid=0)
and trying use this:
nxu::nxuphysicscollection* collection = new nxu::nxuphysicscollection(); nxactor* actor = *actors++; nxu::addactor(collection, actor, null, null);
but following error:
a reference of type "nxu::nxuphysicscollection&" (not const-qualified) cannot initialised value of type "nxu::nxuphysicscollection*" (this collection parameter, same error appears actor well)
how supposed pass collection , actor parameters function in order work properly?
i tried this:
nxu::addactor(&collection, &actor, null, null);
but doesn''t work either, gives me error:
"initial value of reference non-const must lvalue."
any appreciated.
edit: if use this:
nxu::addactor((nxu::nxuphysicscollection&)collection, (nxactor&)actor, null, null);
it not give me errors anymore. correct?
i must mention nxu , nx namespaces closed source , cannot modify way implemented
since formal arguments of member function c
, a
references, while collection
, actor
pointers, need dereference pointers make them compatible references:
// no need pass nulls defaulted parameters, // trailing null, null removed. nxu::addactor(*collection, *actor);
alternatively, can change signature of constructor accept pointers instead of references:
addactor (nxuphysicscollection *c, nxactor *a, const char *userproperties=0, const char *actorid=0) // ^ ^ // | | // here , here
Comments
Post a Comment