If I have declared variables in another function such as main, how do I access them in another function? (Instructor does not allow global variables)
Printable View
If I have declared variables in another function such as main, how do I access them in another function? (Instructor does not allow global variables)
100 bottles of beer on the wall, 100 bottles of beer, take one down pass it around, 99 bottles of beer on the wall....
though here I'm taking your "access them in another function" rather literally by passing by reference.Code:void f(int& x) {
// ...
}
int main() {
int x = 0;
f(x);
}