最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

static

运维笔记admin47浏览0评论

static

static

static_cast 和C风格的转换有什么区别?(What is the difference between static_cast and C style casting?)

有没有理由喜欢static_cast<>超过C风格的投射? 他们是等同的吗? 他们有什么差别吗?

Is there any reason to prefer static_cast<> over C style casting? Are they equivalent? Is their any sort of speed difference?

最满意答案

编译器检查C ++样式转换。 C样式转换在运行时不会失败

也可以轻松地搜索c ++风格的转换,而很难搜索c风格的转换

另外一个很大的好处是,4种不同的C ++风格的演员更清楚地表达了程序员的意图。

在编写C ++时,我总是使用C语言C语言。

C++ style casts are checked by the compiler. C style casts aren't and can fail at runtime

also, c++ style casts can be searched for easily, whereas it's really hard to search for c style casts

Another big benefit is that the 4 different C++ style casts express the intent of the programmer more clearly.

When writing C++ I'd pretty much always use the C++ ones over the the C style.

发布评论

评论列表(0)

  1. 暂无评论