c++ - Passing pointer to a reference to pointer argument -
i migrating old code solaris linux. have lot of functions accept reference pointer arguments such -
static type getinstrument(const item*& item);
now, while calling function have lots of constructs such -
int test(item *l_item) { type lval = getintrument((const item*)l_item); }
this fails compile , match function definition. suggestions how should pass parameters in case?
the function expects reference pointer const
, suffices cast reference of right type:
type lval = getintrument(const_cast<const item*&>(l_item));
where have used const_cast
instead of c-style cast express intent more clearly. have worked too: (const item*&)l_item
.
Comments
Post a Comment