Hello, I was hoping that someone could help me with this question. We received an extra credit queston which completely bombed on. That wasnt the problem, the problem was that I still cannot explain the questions below and since this was extra credit the professor would not give us the answer. Is there a site or book that would explain this.
Any help would be greatly appreciated
Thanks in advance
Code:void f ( ) { cout<< "x is " << x << " and y is " << y << "\n"; } void g ( ) { int y = 20; f ( ) ; } void h ( ) { int y = 30; f ( ); } void main ( ) { int x = 10; g ( ); h ( ); }
1. Explain why the following program is illegal in standard C/C++.
2. Referring to your answer to (1.), explain why the following program would be legal if C/C++ were made into a dynamically scoped language.
3. If C/C++ were made into a dynamically scoped language, what would main () output?