|
-
Jul 14th, 2000, 11:29 PM
#1
Thread Starter
Hyperactive Member
How would I exit a function or procedure? I'm new to this
-
Jul 15th, 2000, 06:41 AM
#2
Monday Morning Lunatic
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
-
Jul 15th, 2000, 11:20 AM
#3
If you use a void, then you do not need to return anything.
-
Jul 16th, 2000, 07:10 AM
#4
Monday Morning Lunatic
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|