Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Error

Status
Not open for further replies.

tramimaus

IS-IT--Management
Sep 23, 2004
15
US
Hi!

Can somebody help me out?
I get a syntax error, when I try to compile this code.
The syntax error indicates,that I'm missing something before the else if(riid==IID_IX).

Can somebody help me out? Thanks!

if (riid == IID_IUnknown)

*ppvObject = static_cast<IUnknown*>
else if(riid == IID_IX)
*ppvObject = static_cast<IX*>(this);
else if(riid == IID_IY)
*ppvObject = static_cast<IY*>(this);

else
{
ppvObject = NULL;
hr = E_NOINTERFACE;
}
 
Add semicolon to terminate an assignment...
 
Code:
*ppvObject = static_cast<IUnknown*>
That is not a complete static_cast. You forgot the (this); at the end.
 
Thanks!

I inserted the (this); but now I get another error: 'static_cast':ambiguos conversion

if (riid == IID_IUnknown)

*ppvObject = static_cast<IUnknown*>(this);
else if(riid == IID_IX)
*ppvObject = static_cast<IX*>(this);
else if(riid == IID_IY)
*ppvObject = static_cast<IY*>(this);

any ideas?
 
What type of object is 'ppvObject' and what type of object is 'this'? You can't cast them unless they are similar types (i.e. inherited). You could try changing the static_cast to a dynamic_cast or as a last resort reinterpret_cast.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top