You can think of it this way: When you call a function... the function call itself is "replaced" with whatever that function returned:
1 2 3 4 5 6 7 8 9 10 11 12
int func() // func returns 5
{
return 5;
}
int main()
{
int foo = func(); // call 'func', and assign whatever it returns to our 'foo' variable
// since func returns 5, this means that foo==5
cout << foo; // this will print 5
}
I suggest you start by reading a tutorial about functions the following link http://www.cplusplus.com/doc/tutorial/ has a fairly good beginning tutorial on functions. You may want to Bookmark this link for future reference.