指向指针的指针 [英] Pointer to Pointer to Pointer

查看:115
本文介绍了指向指针的指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

用于多级指针解引用

我正在读另一篇文章,这导致我这个问题。这是什么意思?还有人们走多远有一个指针指针指向指针的指针....我知道指针的指针,但为什么你会去更多之后?你使用 * *有多深?

I was reading another post and this led me to this question. What the heck would something like this mean? Also how deep do people go with a pointer to a pointer to a pointer to a pointer.... I understand Pointer to Pointer but why else you would go more after that? how deep have you gone in using **?

Foo(SomePtr *** hello);

Foo(SomePtr*** hello);

推荐答案

在C中它很可能显示在哪里:

In C it may well show up where:


    <
  • 你有这样的指针集合作为动态分配的数组,因此T *

  • 您想要获取一个数组,以便传递T ***,并使用T **(T *指针数组)填充您的指针, 。

这将是有效的C,但在C ++中:

This would be valid C but in C++:


  • 第一步是相同的。

  • 第二部分会因使用向量而不是数组而有所不同。

  • 第三部分会因使用引用而不是指针而有所不同。因此,通过将向量< T *>& (或向量< shared_ptr< T>>& code>不是T ***

  • The first step would be the same. You still allocate the objects on the heap and have pointers to them.
  • The second part would vary as you would use vector and not arrays.
  • The 3rd part would vary as you would use a reference not a pointer. Thus you would get the vector by passing in vector<T*>& (or vector<shared_ptr<T> >& not T***

这篇关于指向指针的指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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