c++中的類型轉換--reinterpret_cast

原文連接:  淺析c++中的類型轉換--reinterpret_cast 轉換
c++

reinterpret_cast做用爲:
容許將任何指針轉換爲任何其餘指針類型。 也容許將任何整數類型轉換爲任何指針類型以及反向轉換。express

看着上面的描述就有種放浪形骸的趕腳。更會讓人毛骨悚然,太隨意!.net

語法仍是老樣子:
reinterpret_cast < type-id > ( expression )指針

濫用 reinterpret_cast 運算符可能很容易帶來風險。 除非所需轉換自己是低級別的,不然應使用其餘強制轉換運算符之一。blog

相關文章
相關標籤/搜索