CS250 Some Final Review Questions
Chapter 5 Pointers and Strings
For question 1, use array notation and
then pointer notation in your solution.
The function atoi accepts a string
and returns the string converted to an integer. The prototype is:
int atoi (char s[]);
- The function itoa accepts an
integer and returns the integer converted to a string. Return a
pointer to the newly created string. Dynamically allocate the string
memory.
Chapter 6 Classes and Data
Abstraction
Declare a class called MyString that contains space for up to 256 characters including the null
character and an integer size that contains the length of the
string. Your class is to have two different constructors: a) accepts
nothing and initializes the string to empty and b) accepts a
character string initializing the string and size appropriately.
- How would you use a default
arguments with the constructor to initialize the string to empty?
- Add methods setString, getString,
and concatString to your class.
Chapter 7 Classes Part II
-
Rework questions 1-3 above using dynamic memory allocation
- A destructor was not necessary in
your previous solution. Why?
- Add a destructor to the dynamic
version you just implemented.
Chapter 8 Operator Overloading
-
For the class implemented above, overload the operators >>, <<, ==, and !=.
Chapter 9 Inheritance
Write the header file for a base
class Student.
- Using inheritance write the header
file for a derived class GradStudent and UndergradStudent. You
decide what goes into the making of each class.
- Create an array that is capable of
storing up to 100 graduate or undergraduate students.
- Implement a static data member
that maintains a count of the number of employees.
Chapter 10 Polymorphism
What is the purpose of an abstract
class?
- Give a reason for using a pure
virtual function as opposed to a virtual function.
- What is polymorphism?
- Discuss the term dynamic
binding.
- How might polymorphism be used in
the Chapter 9 example?
Chapter 11 Templates
Work p. 11.3 on p. 735.
Note1: These are just some sample
review questions for the final if you are looking for additional
study problems.
Note2: I will not have time to provide
answers to these questions.