CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17

Thread: Exceptions

  1. #16
    Join Date
    Dec 2003
    Posts
    220
    Originally posted by abc_coder
    it's the intended behavior. Constructors don't return error codes so if you do a one-step (i.e. in the constructor) initialization of some resource and that fails, the most dirrect way of announcing the failure is by throwing an exception. (there are other less direct ways too, but you have to revert to C-style error checking)

    also, to handle the cleanup (if you're throwing from a constructor, *this is not completely constructed and thus the destructor won't be called), constructor initializers are handy: any subobjects will be in a definite state and will be handled nicely by the exception cleanup procedure.
    Thanks a lot,

    Regards,

    Fiona
    Last edited by Homestead; January 10th, 2004 at 08:55 PM.

  2. #17
    Join Date
    Dec 2003
    Posts
    220
    Originally posted by Mick
    let me add it's perfectly legal to throw a exception in a ctor, it's just that you have to make sure you clean up any thing you have allocated.

    /that is all, move along now..
    try {

    I misunderstood. I thought there was ONLY one person here who had the Standard. I m really sorry.

    But then you must understand that I am true to you with all my heart.right ? Please go on helping me...


    Yes, now I also learn that it is perfectly legal to throw AN exception in a ctor, it's just that you have to make sure you clean up any thing you have allocated.

    Congratulations ! Wish you a happy ending, man-to-male marriage...}
    catch { }
    Last edited by Homestead; January 10th, 2004 at 10:42 PM.

Page 2 of 2 FirstFirst 12

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)