Because snarkiness doesn't actually help the OP. A reasonably useful answer would include the caveats.
You are never allowed to access variables in other functions without some effort. You have to tell the other functions where they are and how to access them.
For example, the following program lets the ask_name() function see and modify the name variable in main(), via an alias (or reference):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
#include <string>
usingnamespace std;
void ask_name( string& answer )
{
cout << "What is your name? ";
getline( cin, answer );
}
int main()
{
string name;
ask_name( name );
cout << "Hello, " << name << "!\n";
}
If main() did not give ask_name() access to the 'name' variable, then ask_name() would not have been able to see or change it.
[edit]
Also, notice how ask_name() doesn't know anything about the actual variable's name. It has it's own alias for it -- answer.
[/edit]