【问题标题】:Difficulty to figure out what (uint8_t const * const *) means in .Net terms很难弄清楚 (uint8_t const * const *) 在.Net 术语中的含义
【发布时间】:2015-08-03 22:14:16
【问题描述】:

我正在阅读 C++ 代码,我正在努力理解这个演员表:

(uint8_t const * const *) someVideoFrame->someData

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

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

就步骤而言,这个演员想要达到什么目的? C++ 中的const 效果是什么?

编辑

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

int const * const Constant4

... 声明 Constant4 是指向常量整数的常量指针。基本上,“const”适用于其最左边的任何东西(除非那里没有任何东西,在这种情况下它适用于它最右边的任何东西)。

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

【问题讨论】:

    标签: c# c++ pointers porting


    【解决方案1】:

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

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

    如果您想了解有关阅读指针声明的更多信息并尽可能做到最好,我强烈推荐learning the "spiral rule"。虽然老了,但我发现它超级好用,而且助记词真的很容易掌握。

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

    【讨论】:

      猜你喜欢
      • 2020-11-07
      • 1970-01-01
      • 2016-05-01
      • 2021-12-30
      • 1970-01-01
      • 2015-07-16
      • 2011-09-03
      • 2011-10-21
      • 2012-04-19
      相关资源
      最近更新 更多