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
    684
    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
    23,786
    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?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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, 09: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, 11:38 AM
  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, 12: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, 04:10 PM
  5. 2 quick questions
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 11-28-2001, 11:32 PM

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