Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Is there any CInt function - VB in c++?

Is there any CInt function - VB in c++?

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
23 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Maxwell Chen

    Stephen Hewitt wrote:

    any C-style casts; they should never be used in C++ code.

    Personally I guess that the 1-voter doesn't feel comfortable with the sentence above.


    Maxwell Chen

    S Offline
    S Offline
    Stephen Hewitt
    wrote on last edited by
    #21

    I would guess so - nevertheless they shouldn't be used. Here are some reasons: - A wrong "bad" can cause havoc yet, if C-style casts are used you can’t “grep” the source code for them. - There are many distinct reasons to cast. For example, one is to remove const-ness; another is to “down-cast” in a class hierarchy. With C-style casts all casts look the same and so you have to guess at the intent. Function style casts are explicit and self documenting in this respect. - With C-style casts a simple mistake can change the type of cast and result in unintentional behaviour. For example if your casting to remove const-ness and then you change the type you’re casting it can changes into a “reinterpret” cast. With function style casts the compiler makes sure you can’t cast “more” then you should. i.e. a const_cast can only remove const-ness and not change the type. - Casting is ugly – a well designed program shouldn’t have any – or at most only a few in the lowest level of a system. Casts should be ugly as design errors should be visible. I could go on. There are just so many problems it just not funny. Steve

    M 1 Reply Last reply
    0
    • S Stephen Hewitt

      I would guess so - nevertheless they shouldn't be used. Here are some reasons: - A wrong "bad" can cause havoc yet, if C-style casts are used you can’t “grep” the source code for them. - There are many distinct reasons to cast. For example, one is to remove const-ness; another is to “down-cast” in a class hierarchy. With C-style casts all casts look the same and so you have to guess at the intent. Function style casts are explicit and self documenting in this respect. - With C-style casts a simple mistake can change the type of cast and result in unintentional behaviour. For example if your casting to remove const-ness and then you change the type you’re casting it can changes into a “reinterpret” cast. With function style casts the compiler makes sure you can’t cast “more” then you should. i.e. a const_cast can only remove const-ness and not change the type. - Casting is ugly – a well designed program shouldn’t have any – or at most only a few in the lowest level of a system. Casts should be ugly as design errors should be visible. I could go on. There are just so many problems it just not funny. Steve

      M Offline
      M Offline
      Maxwell Chen
      wrote on last edited by
      #22

      Stephen Hewitt wrote:

      I could go on. There are just so many problems it just not funny.

      What did you mean by that?


      Maxwell Chen

      S 1 Reply Last reply
      0
      • M Maxwell Chen

        Stephen Hewitt wrote:

        I could go on. There are just so many problems it just not funny.

        What did you mean by that?


        Maxwell Chen

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #23

        Only that I could have made the list of problems with C-style casts longer. Steve

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups