Invalid conversion from Foo ** to void ** - why is implicit type conversion allowed to void * but not void **?

struct Foo {};
...
void * p = (Foo*)0; // OK
void ** pp = (Foo**)0; // Invalid conversion

      

As far as I remember, a pointer to any non-pointer type can be implicitly cast to void*

in C ++. Why, then, is the same not allowed for casting a ponter to a pointer type to void**

?

0


source to share


1 answer


A pointer can be implicitly cast to void *

because it void *

is a shared pointer. However, void **

it is not a generic pointer to pointer.



C FAQ 4.9 explains why there is no generic pointer to pointer type in C, I think this applies to C ++ as well.

+3


source







All Articles