📜  c++ 泛型指针 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:44.948000             🧑  作者: Mango

代码示例1
void*  gp;    //generic pointer
int*  ip;     //int pointer
char*  cp;    //char pointer

gp = ip;      //legal conversion
ip = static_cast(gp); //explicit cast required
                            //in C++ but not in C
cp = ip;      //illegal conversion
*ip = 15;     //legal dereference of pointer to int
*ip = *gp;    //illegal generic pointer dereference