Transferring data across functions

So this is not a thread where you need to check my code... hopefully.

I was making an exercise ConsoleApp. in which the user has to choose the type of phone/tablet they want.

So instead of entering all that code into just my...
int main()

I decided to make separate functions for each of the menu options...
Here is an example.

Choice 1. Phone
Choice 2. Tablet


So the functions for that would be...

For Choice 1 int phonemenu()
For Choice 2 int tabletmenu()

This is where the user selects their tablet and the int main() will redirect them to the function

float calculater()

Where the calculation of the prices of the tablet/phone will take place.

What I want to know is how do I transfer this data (Menu Selection, Price, and etc.) across different functions.

I do know that the type of function such as

void foo() -- Returns no value
int foo() -- Returns int value

And I thought that if I did...

return bar;

I would be able to use bar anywhere. Sadly, I was wrong. What must I do?

I am an extreme beginner, so please. Have mercy.
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.

@jib, @Disch +1

Thank you both ^_^ I finally figured it out.
Topic archived. No new replies allowed.