A pointer pointing to any object type can be assigned to a variable of Type void *, void * can be assigned to another void *, and two voids * can be equal or not, in addition, you can explicitly convert void * to another type. Other operations are not safe, because the compiler does not know which object is actually referred. Therefore, any other operations on Void * will cause compilation errors. To use void *, you must explicitly convert to a pointer to a specific type.
Example:
Void test (int * PI)
{
Void * Pv = PI; // OK, implicit conversion from int * to void *
* PV; // error: void * cannot be referenced indirectly
PV ++; // error: void * cannot be incremental (the size of the specified type is unknown)
Int * PI1 = static_cast <int *> (PV); // OK: explicitly converted back to int *
Double * Pi2 = PV; // Error
Double * PI3 = PI; // Error
Double * PI4 = static_cast <double *> (PV); // OK: insecure
}
1. In general, if a pointer is converted ("forced", cast) to a pointer different from the actual type of the object to be approved, using the last pointer is insecure. The most important purpose of void * is to pass a pointer to the function goods, and the object type cannot be assumed. In addition, a non-type object is returned from the function. Use such an object. You must use explicit type conversion.
2. the pointer to the function and the pointer to the member cannot be assigned to void *