Quick questions i was curious about

This is a discussion on Quick questions i was curious about within the C++ Programming forums, part of the General Programming Boards category; 1. What is the difference about static_cast and reinterpret_cast 2. Can the data type of a pointer be explicitly converted. ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    17

    Quick questions i was curious about

    1. What is the difference about static_cast and reinterpret_cast
    2. Can the data type of a pointer be explicitly converted. I tried doing a conversion with static_cast and reinterpret_cast

  2. #2
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    682
    Quote Originally Posted by mdennis10 View Post
    1. What is the difference about static_cast and reinterpret_cast
    There were hundreds of such questions.

    Quote Originally Posted by mdennis10 View Post
    2. Can the data type of a pointer be explicitly converted. I tried doing a conversion with static_cast and reinterpret_cast
    Converted to what, it depends. Any pointer can be converted to/from void* (without reinterpret_cast).
    I never put signature, but I decided to make an exception.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,264
    Quote Originally Posted by mdennis10
    1. What is the difference about static_cast and reinterpret_cast
    There are more details than this, but the meat as quoted from the C++ standard:
    • An expression e can be explicitly converted to a type T using a static_cast of the form static_cast<T>(e) if the declaration “T t(e);” is well-formed, for some invented temporary variable t.
    • The mapping performed by reinterpret_cast is implementation-defined. [Note: it might, or might not, produce a representation different from the original value. ]


    Quote Originally Posted by mdennis10
    2. Can the data type of a pointer be explicitly converted. I tried doing a conversion with static_cast and reinterpret_cast
    Converted from what to what?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2 quick questions
    By Unregistered in forum C Programming
    Replies: 6
    Last Post: 03-02-2002, 10:37 AM
  2. Quick question...I'm curious
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 01-13-2002, 12:38 PM
  3. Another Quick Question....I'm a really curious Person
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 01-12-2002, 01:37 AM
  4. Another Quick Question....I'm a really curious Person
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-02-2002, 05:10 PM
  5. 2 quick questions
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 11-29-2001, 12:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21