gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 02:38:49 24 4
gpt4 key购买 nike

我正在阅读 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com