Int from file to file

Why this is not working?

1
2
3
4
5
6
7
8
//...
void variables()
{
 //...
int f1, f2;
string a;
//...
}


1
2
3
4
5
6
7
8
9
10
11
//...
int main();
{
variables;
cin a;
if (a==1)
{
f1=f1+1;
}

}


The program is more complicated but this is an small example, it gived me something like the main files dosent have the "f1" variable, i want to use 1 file to give all the variables on more files. Please help me! Thanks in advance!
This really doesn't have anything to do with working with multiple files, it is a variable scope issue. Perhaps you need to review your documentation about variable scope.

http://www.cplusplus.com/doc/tutorial/namespaces/

I mean, i want to use one class to define the variables, i dont want to rewrite in every file, like an global global files variables.
to make a global variable, declare it outside of any function(remove variables() and the { }) - although it is not recommended to do this.
Topic archived. No new replies allowed.