Thread: Moving on
View Single Post
Old
legolizard
Senior Member
 
legolizard's Avatar
 
Status: Offline
Posts: 242
Join Date: Jan 2011
Location: Aboard the Hyperion escaping the zerg.
Default 08-07-2011, 07:14 PM

You will problably read up on this later in your book, but here is my expanation if what it is.

Since the main() is of integer type meaning that it has the int keyword it must return a value. See there two primary types of functions ,functions that return values and functions that return nothing.Any function with the keyword void at the beggining does not return anything. Every other function must return something. For example:

Code:
int foo()
{
//Some code
}
returns an integer.

while

Code:
string boo()
{
//Some code
}
returns a string.

Now every function that returns something must have a return statment and then a value or variable that you want to return.

So you would get:

Code:
int foo()
{
return 5; 
}
So this means that when foo is finsihed executing it will return the value 5.

Now what this return statment does is basically makes the value of foo eqaul to 5.

So to summarize return 0; basically returns the integer 0 back to the main().

Does that make sense? If it does not I can make a example program for you.


"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."-Albert Einstein
   
Reply With Quote