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. Constructors - throw an exception if failed

Constructors - throw an exception if failed

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
3 Posts 2 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.
  • T Offline
    T Offline
    tom76
    wrote on last edited by
    #1

    Hi all, I want my constructors (default, overloaded, and copy) to throw an exception if they fail. My questions are 1) How can I test to see if the constructor has failed? 2) Should I create an exception class to throw exception objects rather than using text strings/integer codes? 3) Where does the catch block go? In the constructor body, or after creating an object in the .cpp file? Thanks, Daniel Obseve everything, remember more...

    T 1 Reply Last reply
    0
    • T tom76

      Hi all, I want my constructors (default, overloaded, and copy) to throw an exception if they fail. My questions are 1) How can I test to see if the constructor has failed? 2) Should I create an exception class to throw exception objects rather than using text strings/integer codes? 3) Where does the catch block go? In the constructor body, or after creating an object in the .cpp file? Thanks, Daniel Obseve everything, remember more...

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Check this: http://www.gotw.ca/gotw/066.htm Tomasz Sowinski -- http://www.shooltz.com

      - It's for protection
      - Protection from what? Zee Germans?

      T 1 Reply Last reply
      0
      • T Tomasz Sowinski

        Check this: http://www.gotw.ca/gotw/066.htm Tomasz Sowinski -- http://www.shooltz.com

        - It's for protection
        - Protection from what? Zee Germans?

        T Offline
        T Offline
        tom76
        wrote on last edited by
        #3

        That's very handy, thank you. I'm going to play with one of the examples to see how I go. Annoyingly the bits I need are not written in, it's just //... Grrr! Daniel:confused: Obseve everything, remember more...

        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