0

I am trying to write two functions, one calls the other and passes in an argument:

int RegisterImage( const char * streamID, IMGStream & c ) {
...
}

int OpenImage( const char * streamid, int dsize ) {
ImageStream * im;
int idx = -1;

if ( GetImgRegIdx(streamid, dsize, im) )
          idx = RegisterImage (streamid, im);
return idx;
}

The calling of "RegisterImage()" fails. It complains about: "in passing argument 2 of ‘int Core::RegisterImage(const char*, IMGStream&)’"

Can anybody help me understand why it's complaining, and how to fix it? Thanks so much

1
  • What's the relationship between IMGStream and ImageStream? Commented Dec 10, 2013 at 1:21

3 Answers 3

1

ImageStream * im; is a pointer, your RegisterIMage() expects a reference as its second argument. You need to pass in *im. References implicitly refer to objects, not to addresses. Your ImageStream* is type that holds an address.

Sign up to request clarification or add additional context in comments.

Comments

0

Assuming IMGStream and ImageStream objects are the same type (one being a typedef of the other or something), then the function is expecting a reference and you're passing a pointer.

So, if IMGStream and ImageStream objects are actually the same type, you should pass *im instead of im.

Comments

0

It's asking for an IMGStream& which you read as 'IMGStream Reference'. Although this acts very much like passing a pointer, the syntax must not be.

Try de-referencing your pointer with a * (the de-reference operator)

     idx = RegisterImage (streamid, *im);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.