Use of void** in QueryInterface (COM)

Use of void** in QueryInterface (COM)

When using Queryinterface in COM, why is the interface pointer cast to void** andwhy is it passed as a pointer to a pointer (double indirection)?

This is because the function that accepts the void** pointer changes its value.

In general, when you call a function that changes the value of an int, you pass an int * to that function. However, when the argument to be changed is itself a pointer, you need to pass that pointer’s address. In other words, you pass a pointer to a pointer. This exactly what void** is.


Share the Post: