1b. Draw a diagram using the UML that shows a binding between a Variable
and its Type.
Question 2
2a. What are: coercion, type checking, strong typing, and type compatibility?
2b. Describe the good and bad points of strong typing .
Question 3
3a. Define static scoping and dynamic scoping.
3b. What does this C++ program output:
#include <iostream>
using namespace std;
int i =1;
void f(int n){ cout <<n <<": "<< i; }
int main()
{ int i=2;
f(3);
}
Fill in the blank: This output shows that C++ functions use ____________ scoping.
3c. What does this C++ program output:
#include <iostream>
using namespace std;
int i =1;
#define f(n) {cout <<n <<": "<< i;}
int main()
{ int i=2;
f(3);
}
Fill in the blank: This output shows that a C++ macro (#define) uses ____________ scoping.
3d. Compare the advantages and disadvantages of these two scoping methods.
Question 4
Storage bindings. In C++ how do you create the following types of storage:
How are following kinds of storage in C++ deallocated?
Project
You are designing a new language. You must decide (and justify) the issues
and options raised in this chapter on names. Will your language be
sensitive to case? (why?). Will you have reserved words or key words?
(Why?) What is the scope of a variable? Will it be resolved statically or
dynamically? (WHY!)
Answers
Answers to questions 1, 2, and 4 should be checked against the book. Check
3 online and in the book.