Question: 2. Pointers present some special problems for overload resolution. Consider the following C++ code: void f( int x){} void f( char x){} int main (

 2. Pointers present some special problems for overload resolution. Consider the
following C++ code: void f( int x){} void f( char x){} int
main ( {f(0); What is wrong with this code? How might you

2. Pointers present some special problems for overload resolution. Consider the following C++ code: void f( int x){} void f( char x){} int main ( {f(0); What is wrong with this code? How might you fix it? Can this nroblem also occur in Java? 3. Consider the following pseudocode: 1. procedure main0 2. a : integer:=3 3. b: integer : =5 4. c: integer :=7 5. procedure first O 6. b : integer := c 7. c: integer :=b 8. procedure second0 9. print a, b, c 10. a: integer : =2 11. --body of first 12. second O 13. print a,b,c 14. --body of main 15. first ) 16. print a,b,c Suppose this was code for a language with the declaration-order rules of C (but with nested subroutines) - that is, names must be declared before use, and the scope of a name extends from its declaration through the end of the block. At each print statement, indicate which declarations of a,b and c are in the referencing environment. What does the program print (or will the compiler identify static semantic errors)? Repeat the exercise for the declaration-order rules of C\# (names must be declared before use, but the scope of a name is the entire block in which it is declared). 4. The following program prints two integer values; the first value typically is garbage (or possibly 0 , if you are executing inside a debugger or other controlled environment), but the second value might be 2 . Explain why. \#include stdio.h > main() \{ { int x printf("\%d \ n", x); x=2 3 \{int y; printf("\%dn",y); \} return 0 ; \} 5. Consider the code below: Explain what function g() returns assuming that macro expansion (textual substitution) is used as a mechanism for passing parameters. Do the same exercise for call-by-value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!