How do you cin parameters?

This is a discussion on How do you cin parameters? within the C++ Programming forums, part of the General Programming Boards category; How do you create a function that takes user-defined parameters? For example, say I had a function:
Code:
int Example(int ...

Am I able to eliminate "int a" and "int b" from main somehow? I mean it works fine, but is it bad practice to have them there?

Sorry for being noob

Thanks again.

there's absolutely nothing wrong with having them there. in fact, it's where they belong in a program like yours. making them global (outside the scope of any class, namespace, or function) would be very bad. it is best to avoid global variables whenever possible. it is sometimes necessary to have them, but those situations are not nearly as common as the actual usage of global variables.

Yah, I was just trying to create a simple example that I could apply to my current project.

I recently decided to take a second major in CS which will be in affect as of next semester (starting in 2 weeks) and couldn't wait to get started so I decided to learn C++ by creating a program that a friend could use for actuarial studies. I had originally just written it as a list of commands and although it worked quite well, I wanted to practice writing it properly. Although I suspect it's not a lot better, I have managed to make all the variables used in calculations private at least and all the calculations are organised into various classes in separate files. The only public variables are 5 strings that are used to navigate between the various menus with lists of equations.

I asked about the function that could take user defined parameters as I was trying to separate the calculation and the interaction with the user somehow. For example, most of my functions look something like this: