Why do we have pointers other than void

前端 未结 10 962
攒了一身酷
攒了一身酷 2020-12-30 22:54

I know that we have different pointers like int, float, and char. A void pointer is the only pointer which can hold all o

10条回答
  •  無奈伤痛
    2020-12-30 22:54

    Dead simple:

    void* p;
    *p; // compile error!
    

    Or to put it in words; a void pointer can not be dereferenced.

    Perhaps you should rename the question why do we have pointers, or rather don't and just search for that question on SO.

提交回复
热议问题