Difference between static_cast and (char*)

后端 未结 5 1807
天命终不由人
天命终不由人 2020-12-20 18:43

this is my first question :)

I have one pile file, and I have open it like shown below ;

ifstream in ( filename,  ios :: binary | ios :: in ) 
         


        
5条回答
  •  一个人的身影
    2020-12-20 19:04

    • first - you can easily search for _cast and find any c++ cast. Searching c-style casts is a lot harder.
    • second - if you use c++ casts, you need to choose the correct one. In your case, it is reinterpret_cast.
      The c-style cast does everything.

    you can also check here: http://www.cplusplus.com/doc/tutorial/typecasting/ for the differences of the different c++ casts. I strongly recommend only to use c++ casts. This way you can easily find & check them later and you are forced to think about what you are actually doing there. This improves code quality!

提交回复
热议问题