1. Suppose someone designed a stack abstract data type in which the function top returned an access path (or pointer) rather than returning a copy of the top element. This is not a true data abstraction. Why? Give an example that illustrates the problem.
2. Describe the three ways a client can reference a name from a namespace in C++.
3. Compare the dynamic binding of C++ and Java.
4. Compare the multiple inheritance of C++ with that provided by interfaces in Java.
5. Using the grammar in Example 3.2, show a parse tree and a leftmost derivation for each of the following statements:
A = A * (B + (C * A))
6. Consider the following grammar:
< S> -> a < S> c < B> | < A> | b
< A> -> c < A> | c
< B> -> d | < A>
Which of the following sentences are in the language generated by this grammar?
a. abcd
b. acccbd
c. acccbcc
d. acd
e. accc
The goal of this exercise is to use some of the object oriented features of C++ or Java.
The program is to simulate a tennis tournament, for our purposes, takes a field of 8 players and plays a series of three rounds, eliminating half the players with each round - ending with a single (winning) player.
Individual rounds operate as follows:
The user should enter the names of the 8 players, then the program should simulate each of the three rounds, printing the result of each game.
At the end of the tournament the program should print the name of the winner and the name of the second place finisher.
Your software must include appropriate classes of object for both a player and a tournament, but beyond that the design is at your discretion.
In addition, the simulation between any two players is as follows: