1. Give the complete name each of the following gdb commands and write a complete sentence telling what each one does:

  1. b
  2. c
  3. n
  4. p
  5. q
  6. r
  7. s

Hints (in random order): terminate, set breakpoint, single-step (two ways), show value, start execution, resume after breakpoint.

2. Explain the difference between the two selection operators, '.' (dot) and '->'.

3. Tell the difference between an inline function and a normal function.

4. Assume there is a header file named someclass.h that declares a class named SomeClass that has 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, returns an int, and which can be used for const objects of the class. The class also has a private int data member. Write a program that defines objects of SomeClass with the following names and characteristics:

  1. gc, an object which can be accessed from any function, and which has the constant value of 3.
  2. dl, an object that can be accessed only from main(), and which has whatever initial value is provided by the default constructor.
  3. sl, an object that can be accessed only from a function named foo(), but which will retain its value between calls to foo().

Write your program to do the following: When it starts executing, use getValue() to print the value of gc. Then assign the value 7 to dl and use getValue() to print that. Then call foo() two times and print the value it returns each time. Include the definition for foo(), which is to set the value of sl to one more than its previous value and to return the new value of sl. (Prototype for foo(): ' int foo(void); '

5. Declare a class that keeps track of how many objects of that class exist at any time. (It doesn't have to do anything else useful for this question.) Write definitions for the constructor, the destructor, and a member function that may be used to get the number of objects of the class. Just write the declarations for the relevant parts of this class, no function definitions.

6. What is "default memberwise copy," and how does is relate to overloading the '=' operator?

7. Write the code to declare the part of a class named Aclass that overrides the '+' operator.


Christopher Vickery
Queens College of CUNY