HELP!! Please Explain to me what this means!!?!!?

I opened a .txt file in the main function. Now my instructor said he "passed in the input file stream as a parameter" which I believe is to be in a read function or the prototype: void readData(ifstream& input, int arr[]);

Could someone tell me exactly how he did that and what that actually means.
If you do something in main() and have other functions. They do not know what the values of other functions variables are, so they have to be passed to the other functions.

See my example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>

using namespace std;

void function1 ()
{int x=1;cout << x<< endl;}

void function2 ()
{int x=2;cout << x<< endl;}

void function3 (int x)
{cout << x<< endl;}


int main()
{
int x=0;
cout << x<< endl;
function1 ();
function2 ();
function3 (x);
cout << x<< endl;
return 0;
}


Last edited on
Topic archived. No new replies allowed.