CORRECT ANSWERS
Question:
1. encapsulation
Answer:
separates the implementation details from the public interface
Question:
2. benefits of c++ data abstraction
Answer:
1. data hiding
2. ability to declare multiple of the same object
3. automatic initialization and termination
Question:
3. drawbacks of c++ data abstraction
Answer:
1. error handling is obtrusive
2. function call overhead
Question:
4. can arrays be initialized in BMI?
Answer:
yes
Question:
5. member initialization list order
Answer:
1. virtual base class sub-objects (no matter where they occur in hierarchy)
2. non-virtual immediate base classes in the order they appear in base class list
3. the class data members in order they are declared
Question:
6. copy constructor
Answer:
initialize an object with a different object of the same type
can be called with an = if you are making a new object (std::string s = t)
Question:
7. assignment operator
Answer:
copies the value from one object to another of the same type
, Question:
8. shallow vs. deep copy
Answer:
shallow copies make copies of only the objects' references, not the actual objects
--> when original object is changed, new object also changes
deep copies make copies of the actual data and objects referred to by the original object
when object being copied only has data structures or primitives, shallow and deep are the same, but if there
are pointers they are different
Question:
9. the big 3
Answer:
destructor, copy constructor, assignment operator (operator=)
Question:
10. initialization vs. assignment
Answer:
initialization: the process of turning raw storage into an object
assignment: the process of replacing the existing state of a well-defined object with a new state (never
performed on raw storage)
Question:
11. stages of c++ compiler
Answer:
preprocessor compiler assembler linker
Question:
12. preprocessor (role, output, common errors)
Answer:
role: deletes comments, expands macros, replaces file includes and constants
output: individual translation units with headers included, comments removed, and macros tmpl. expanded
common errors: don't use macros or define constants, don't pollute namespace with C libraries, understand
how template instantiation works
Question:
13. compiler (role, output, common errors)
Answer:
role: takes code and produces architecture dependent assembly code; apply rules of c++
output: individual translation units in assemble code
common errors: type errors, syntax errors, grammar errors
Question:
14. assembler (role, output, common errors)
Answer:
role: translate assemble into platform specific machine code
output: individual translation units in machine code
common errors: none