CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 31

Threaded View

  1. #16
    Join Date
    Aug 2007
    Posts
    858

    Re: reinterpret_cast<> and where can it be used

    Quote Originally Posted by nuzzle View Post
    So what everybody's said in this thread is allright because the C++ standard allows anything; Whatever you say is fine

    The only sensible reaction is to never use reinterpret_cast, at least not if you're aiming for portability.
    That would be a bit silly, sense it would mean that it's impossible to do some very basic things in a portable manner - ie it would be impossible to read or write portable binary files, since stream read and write methods only work on char*'s.

    I haven't read the book in question, but I suspect that you somewhat misread or misunderstood the statement. I imagine the author's intent was to say that the types of actions that require reinterpret_cast are inherently not portable, unless you're careful.

    Edit: Well, it wouldn't be impossible (the binary file thing), but it would require a convoluted method like using a union to be able to get the data as char. I'd say that's considerably worse than reinterpret_cast.
    Last edited by Speedo; August 8th, 2009 at 08:01 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured