c# - 很难弄清楚 (uint8_t const * const *) 在 .Net 术语中的含义

标签 c# c++ pointers porting

我正在阅读 C++ 代码,我正在努力理解这个转换:

(uint8_t const * const *) someVideoFrame->someData

我看到了类似于指向字节数组的指针,但我很难理解双重 constant pointer 的用法。

据我所知,我只是将其移植为 (byte **)。

就步骤而言,这个 Actor 试图达到什么目的? C++ 中的 const 效果是什么?

编辑

同时我在 C++ 文档中发现了这个:

int const * const Constant4

... declares that Constant4 is constant pointer to a constant integer. Basically ‘const’ applies to whatever is on its immediate left (other than if there is nothing there in which case it applies to whatever is its immediate right).

但我仍然想知道动态声明常量的目的是什么。

最佳答案

从右开始向左移动:pointer to const pointer to const uint8_t

   uint8_t const     * const           *
// ^^^^^^^^^^^^^     ^^^^^^^           ^
//               to               to
// const uint8_t <- const pointer <- pointer

如果你想了解更多关于阅读指针声明的知识,并且尽可能好,我强烈推荐 learning the "spiral rule" .虽然老了,但我觉得 super 好用,而且助记词真的很容易掌握。

强制转换可能试图强制您不会错误地修改内部指针(const),也不会错误地修改它指向的数据(也是const).

关于c# - 很难弄清楚 (uint8_t const * const *) 在 .Net 术语中的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30387382/

相关文章:

c# - 更新 Monotouch.Dialog RootElement

pointers - 带指针的 Golang 类型断言

c - free() 使用不同的指针释放相同的堆内存

c - 初始化指向整数的指针数组

c# - 在 ASP.NET 中使用缓存

c# - 为什么一个查询有效而另一个查询无效?

c# - 最佳实践 : Accessor properties or parameterless methods?

c++ - 嵌套结构和数组 C++

c++ - 计算数组中元素出现的频率

c++ - 为什么模板类会有未使用的类型?