Why use static_cast(x) instead of (int)x?

前端 未结 9 1772
滥情空心
滥情空心 2020-11-22 02:38

I\'ve heard that the static_cast function should be preferred to C-style or simple function-style casting. Is this true? Why?

9条回答
  •  攒了一身酷
    2020-11-22 02:42

    static_cast means that you can't accidentally const_cast or reinterpret_cast, which is a good thing.

提交回复
热议问题