I want to get a value in main()
from the functionTwo()
.
The functionOne
is designed to calculate the sum of the functionTwo()
.
Why I cannot use this sentence to pass the j
value to int b
?
int b = functionOne();
//function 0ne
int functionOne(int x) {
static int j = 0;
j = j + x;
return j;
}
//function Two
void functionTwo() {
int a = 10;
for (int i = 0; i < a; i++) {
functionOne(2);
}
}
// print the j value of functionOne in main()
int main()
{
functionTwo();
//Why I cannot use this sentence to pass the j value to "int b"?
int b = functionOne();
cout << "the j value of functionOne in main() is: " << functionOne << endl;
return 0;
}