CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: A question regarding try/catch

    More typically you'd throw in the function and put the try/catch in the function that calls it. That way you'd know if it returned legitimately or threw the exception.

    Code:
    void bar()
    {
        try
        {
              if(foo())
                    ...
        }
        catch(...)
        {
            ...
        }
    }
    If you need the catch in foo, typically returning true would indicate foo succeeded, and false would indicated it didn't.
    Last edited by GCDEF; January 23rd, 2013 at 09:11 PM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured