22C:30, 22C:115 Review for Exam 1
Exam 1 is scheduled for Friday, September 26, from 10:30 to 11:20 in
Room 321, CB
Given below are questions that you should attempt to answer in studying for
These questions will not be on the exam, but understanding the answers to
these questions will help you in solving the problems on the exam.
The problems on the exam will involve (i) answering questions about small code
fragments that are given and (ii) writing small code fragments to perform a
specific task. You will not be asked to write large functions or entire classes.
To prepare for the exam read (i) lecture notes and notes from discussion sections,
(ii) code posted on the course webpages (including the apvector, graph, and
rational classes), and (iii) the following material from the textbook: Chapter 1,
Section 2.3 (on templates), and Section 5.1 (on Vectors).
In general, focus on material that relates to what was discussed in class and in the
- Why is a class definition separated into a public and a private portion?
Can data members go into the public portion of a class? Can member functions
go into the private portion of a class?
- What is the difference between passing parameters by value and passing
parameters by reference? Are there other ways of passing parameters, besides
- Why do functions sometimes return a reference? For example, why does
operator  in the apvector class return a reference?
- Why do classes need destructors? For example, the apvector class has one.
- Why do classes need copy constructors? When are copy constructors called
without an explicit function call?
- What are template classes and what are they good for?
- How can we define a 2-dimensional array using the apvector class?
How can we define a 2-dimensional array using pointers?
- What is the meaning of the operators * and & in the context of pointers?
- What do the new operator and the delete operator do?
- What is the "this" pointer and what is it good for?