Thread: expression execution order

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    245

    expression execution order

    I'd like to call a number of functions, all which can only be called if the previous function succeeded. All functions return bool results, so just wondering what the best way to do this would be.

    I'm currently using the following method:

    Code:
    if (func_a())
       if (func_b())
          if (func_c())
    (etc...)
    but wondering if this would be better:

    Code:
    if (func_a() && func_b() && func_c())
    Problem is, would they all be called regardless of whether the previous one failed, or would execution stop when one of them returned FALSE? Or worse still, is the above unspecified, and depends on compiler?
    Last edited by _Elixia_; 10-02-2003 at 03:32 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. order of execution of tokens in a c++ source code
    By sandy.sandipanc in forum C++ Programming
    Replies: 4
    Last Post: 10-04-2008, 12:34 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. recursion error
    By cchallenged in forum C Programming
    Replies: 2
    Last Post: 12-18-2006, 09:15 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. randomizing order of execution of function
    By y2jasontario in forum C Programming
    Replies: 2
    Last Post: 04-03-2002, 07:50 PM