Results 1 to 4 of 4

Thread: Exiting

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263

    Arrow

    How would I exit a function or procedure? I'm new to this

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Use the return keyword. One thing to note is that you must return a value of the same type as the function's definition:

    Code:
    int myfunc(int i) {
        return i;
    }
    
    bool anotherfunc(int i) {
        if(i > 5) {
            return true;
        } else {
            return false;
    }
    As you can see from the second example, no other statements are executed.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Guest
    If you use a void, then you do not need to return anything.

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    It's impossible to return the wrong type because the compiler will whinge at you.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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