1. (A) Write the command line to start debugging an executable program named myprog using the gdb debugger. (B) Tell what gdb command would be used to set a breakpoint to stop your program when it reaches the function main(). (C) Tell what gdb command would be used to start a program running.

2. Name the two gdb commands for executing a program one statement at a time; tell the difference between the two.

3. If a program contains a variable named aPtr, which is a pointer to a struct, tell how you could use gdb to see (A) the numeric value of the pointer, and (B) the contents of the struct that it points to.

4. In C++, tell the difference between an inline function and a normal function.

5. Write the code to declare a class named SomeClass. The class is to have a constructor that takes an int as its argument, a function named setValue that takes an int as its argument, another function named getValue that takes no arguments and returns an int, and which can be used for const objects of the class, and a private int data member named value. Note: you are to write just the class declaration, not the implementation of the member functions.

6. Write the code to declare another class named Counter that has a data member to keep track of how many objects of that class have been created. Include the parts of the class that define the counter variable and the three functions that increment, decrement, and return the value of the counter, but no other member functions or data members for the class. Note: For this question, you are to write the parts of the class declaration indicated and to include the definitions (not just the declarations) of the three functions indicated.

7. What is the difference between a deep copy and a shallow copy?

8. Write the code to declare the part of a class named String that overrides the + operator to do concatenation. Bonus: (up to 6.25 points) Show the implementation of the function.


Christopher Vickery
Queens College of CUNY