,指定操作数时, C++ 语言指定某些兼容性。下表显示操作数的类型可接受对需要类型 type操作数的运算符。
操作数类型可接受对运算符
预期的类型 |
允许的类型 |
---|---|
type |
const 类型 volatile 类型 type const type volatile type 变量的常量类型 变量的常量 type |
type* |
type* consttype* volatiletype* 变量的常量 |
const type |
typeconst typeconst type |
volatile type |
typevolatile typevolatile type |
由于上述规则始终可以组合使用,可以提供对可变对象的一个 const 指针指针所需的位置。