0
void*
What means void* in c++? How can pointer point at nothing?
4 Answers
+ 2
Void pointersâ come from c. They are useful because they allow you to make a function that uses pointers to different types. (There are no template functionsâ in c.)
qsort is a good example of this, you can pass it an int pointer, or char pointer, etc. Then qsort can sort an array of integers or char etc.
Also malloc uses void pointers so you can allocate memory for any type.
0
@Ace thank you! And how can we use it? I can not understand a prototype of qsort from cstdlib, but, perhaps, there is a less difficult example.
0
Thank you all, it wasn't clear for me for a few years))