CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Posts
    11

    void** in relation to QueryInterface??

    The function prototype for QuerytInterface is this:
    Code:
     STDMETHODIMP QueryInterface( REFIID riid, void** pIFace )
    And calling the QueryInterface function is like this:

    Code:
    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!
    Last edited by SimplySane; August 28th, 2008 at 11:11 AM. Reason: not yet done

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: void** in relation to QueryInterface??

    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.

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: void** in relation to QueryInterface??

    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).
    Best regards,
    Igor

  4. #4

    Re: void** in relation to QueryInterface??

    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured