1. What is the difference between a class and an object?

2. Explain the differences among a struct, a union, and an enum.

3. Write the commands you would type to start a debugging session with an executable file named myprog, to set a breakpoint at the beginning of function myfunc(), to execute the program at full speed until it reaches the breakpoint, to execute exactly two more statements after hitting the breakpoint (do not go into any functions that are referenced on those two lines), to display the value of a variable named myvar, and then to exit the debugger.

4. Write enough of the file, thing.h, so that the following code will compile without any errors or warnings. Hint: This is a question about declaring overloaded operators.

#include <iostream.h>

#include "thing.h"

int main() {

Thing aThing(1), bThing(2);

const Thing cThing(3);

cout << aThing << endl;

aThing = cThing + bThing;

return 0;

}

5. Tell what static, void, and const mean in these two function prototypes:

class SomeClass {

public:

static int foo();

void bar() const;

};

6. Tell what the operator new does.

7. A) Draw a diagram that shows the relationships among the memory cells assigned to ptr, ds_1, ds_2, memb_a, and memb_b. Show where the values 111, 222, 333, and 444 are stored in your diagram:

struct ds {

int memb_a;

int memb_b;

} ds_1 = { 111, 222}, ds_2 = { 333, 444 }, *ptr = &ds_1;

Help: If the example were "int x = 123;" the diagram would look like this:

8. Write two different C++ assignment statements that would change the value of ds_1's memb_a (111) to 555 in the previous question. (Use the two different member selection operators.)

9. Write an implementation of the overloaded '==' operator for the String class defined in Chapter 8. Note: this is '==' not '='.

10. What is the difference between class inheritance and class composition? Tell which one would be used to implement an "is a" relationship, and which one would be used to implement a "has a" relationship.


Christopher Vickery
Queens College of CUNY