c++ - const* 方法参数中的 const

标签 c++ syntax constants

以下函数定义的参数中的 2 个常量意味着什么?

void myFunction (MyClass* const* const myObj);

最佳答案

从右到左阅读:

MyClass* const* const
   ^   ^   ^  ^ ^
   |   |   |  | 1
   |   |   |  |
   |   |   |  2
   |   |   3
   |   4
   5

(1) const (2) 指针 (3) const (4) 指向 MyClass 的指针。换句话说,您无法更改指针,但 MyClass 实例保持可变。

关于c++ - const* 方法参数中的 const,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13833766/

相关文章:

c++ - 比较 double 和 int,无需转换或转换

node.js - coffeescript 中 array.forEach() 的正确语法

c - 我如何将 const 指针发送到 c 中的非 const 指针?

c++ - 在不传递源字符串的情况下在字符串末尾添加字符的宏

c++ - 如何防止从中断例程中调用特定函数或方法?

javascript - ng-include 的正确语法是什么?

c++ - 为什么 std::forward 会丢弃 constexpr-ness?

C++11 move 到本地常量引用 : scope

c++ - std::cbegin() 除了 begin() 一个 const 引用之外还有别的吗?

css - 样式表开头的 ".foo{}"是什么?