DEV Community

yeonseong
yeonseong

Posted on

C style cast vs C++ style cast in C++

conclusion

USE C++ STYLE CAST

    ⭕️ static_cast<float>(_value) 
     (float)_value
Enter fullscreen mode Exit fullscreen mode

reasons

  1. C++ style cast can be check in compile time.
  2. C++ style cast is more spotted easily!

reference

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

Top comments (0)