在運算式中的標記法

指定運算元時,C++ 語言會指定特定的相容性。 下表顯示運算元的型別可接受要求型別的運算元的運算子type。

運算子可接受的運算元型別

預期的型別

允許的型別

type

const 型別

volatile 型別

type&

const type&

volatile type&

動態 const 型別

動態 const type&

型別 *

type* consttype* volatiletype* volatile const

常數 type

typeconst typeconst type&

volatile type

typevolatile typevolatile type&

因為永遠可以結合並同時使用與前述規則,可以預期指標會提供 const 變動的物件指標。

請參閱

參考

運算式的語意