Calling API in C++

I have an API with below signature,

GetNumAvail(const derUtil *,const Invnumfilter &,int);

I have defined a object of Invnumfilt as,

Invnumfilter *filter="92%"; // Filter criteria

while calling the above API as,
GetNumAvail(iord,&(filter),1);

Its throwing a compile time error as,

"Argument of type 'InvNumberFilter **' could not be converted to 'const InvNumberFilter &'. "

How to define a object of 'invnumfilter' and call the API without error?


Any suggestions most welcome,
Yag
InvNumberFilter is probably some kind of "struct" or "class", right? So it should look more like

1
2
3
InvNumFilter filter;
filter.Criteria = "92%"; // or whatever the way is to fill your InvNumFilter
GetNumAvail(iord, filter, 1);

The problem is that GetNumAvail defines a constant reference to Invnumfiler argument const Invnumfilter &, you however pass a pointer to a Invnumfilter pointer &filter with filter being a Invnumfilter*. Basically, as an argument it expects an Invnumfilter but you try to pass an Invnumfilter**. Basically, just write *(filter) instead.

Next problem is a bit more severe though -
Invnumfilter *filter="92%";
You create a new pointer to an invnumfilter here, and assign the address of a string literal to the address of your Invnumfiler. Invnumfilter *filter= new Invnumfilter("92%"); is probably what you wanted to do.
Topic archived. No new replies allowed.