什么是无效*和无效的区别**? [英] What's the difference between void* and void**?

查看:225
本文介绍了什么是无效*和无效的区别**?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是特殊的属性,它的void *也可以分配一个指针的指针和投退,并收到原来的值。

我在其他地方见过这条线。它是否意味着无效* 无效** 相同?
有什么区别?

I read this line somewhere. Does it means void* and void** are same? What is the difference?

修改

无效* 可以持有任何指针。那么什么是无效** 需要?

void* can hold any pointer. Then what's void** needed for?

推荐答案

在一个黑洞点之一。

在在黑洞指向事物的另一点。

The other points at the thing pointing at the black hole.

他们并不是真正的同样的事情,但指针可以转换为无效* 。您可以将为int * 无效* ,因为,这是一个指针。 无效** 还是的指针(它只是指向一个指针),并且由于它是一个指针,你可以将其转换为无效* 。这有什么意义?

They're not really the same thing, but pointers can be converted to void *. You can convert int * to a void * because, well, it's a pointer. void ** is still a pointer (it just points to a pointer), and since it's a pointer, you can convert it to a void *. That make any sense?

这是说,我不认为我曾经有过一个使用无效** ,但如果你需要的数组无效* S,那么该类型是无效** 。 (在C)无效* 经常被用来举办一个指向某些用户数据 - 但你不会预先知道什么类型的数据会。如果你有这些数组,那么无效**

That said, I don't think I've ever had a use for a void **, but if you needed an array of void *s, then the type would be void **. (In C) void * is often used to hold a pointer to some user data - but you won't know ahead of time what type that data will be. If you had an array of those, then void **.

既然你也有这个标记为C ++:在previous情况下,并没有真正适用:你可以使用的std ::矢量<无效*> 。真的,无效* 可能是有问题的 - 一个抽象基可能适合你的目的更好。 无效* 是很有用的大多是用C

Since you also have this tagged as C++: The previous case doesn't really apply: you could use a std::vector<void *>. Really, void * might be questionable - an abstract base might fit your purposes better. void * is useful mostly in C.

这篇关于什么是无效*和无效的区别**?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆