雖然在維基百科上查找運算符關聯性,但我注意到delete
具有從右到左的關聯性。源被引用爲msdn,我檢查了它,它屬於第3組優先級,從右到左的關聯性。所以,我檢查the C++ standard (n4296)運算符刪除關聯
5.3元表達式[expr.unary]
1)表達式與一元運算符組從右到左
unary-expression: postfix-expression ++ cast-expression -- cast-expression unary-operator cast-expression sizeof unary-expression sizeof (type-id) sizeof ... (identifier) alignof (type-id) noexcept-expression new-expression delete-expression unary-operator: one of * & + - ! ~
,這都意味着什麼? delete
究竟有什麼關聯性?
delete * ++ x;如果你在你想刪除的指針前有一個指向指針的指針呢? (從MickLH偷來) – Almo