Click to See Complete Forum and Search --> : void** in relation to QueryInterface??


SimplySane
August 28th, 2008, 11:04 AM
The function prototype for QuerytInterface is this:
STDMETHODIMP QueryInterface( REFIID riid, void** pIFace )

And calling the QueryInterface function is like this:

pICreateCar->QueryInterface( IID_IStats, reinterpret_cast<void**>( &pIStats ) );

What's confusing me is the casting of the address of pIStats to void**
reinterpret_cast<void**>( &pIStats )

What exactly is void** in this context?? Why do we cast the address of the interface ptr to void**??

Thanks!

kirants
August 28th, 2008, 11:38 AM
QueryInterface is used to get an interface pointer to any type of interface, so it makes sense to not have something specific for the secodn parameter isn't it ? Hence the choice of void** and not something like int** or IBlahBlah**

It's to make the compiler happy.

Igor Vartanov
August 29th, 2008, 03:11 AM
What exactly is void** in this context??In this context, and elsewhere, void** is a pointer to pointer to any type of POD/class/structure (not class member or something).

JamesSchumacher
September 3rd, 2008, 11:00 AM
Yes, Igor is correct.

A void * is a pointer that can point at any data, therefore a void ** is a pointer to a void *. (Which defines it as Igor said - common sense)