The final exam is cummulative, but with more of an emphasis on topics covered after the midterm. Therefore, you should first review the study guide we provided for the midterm. The following lists the new topics covered since then: Operator Overloading - What basic concept is - What the corresponding special function names are that should be overloaded - Using member and non-member functions to overload - Why use "return by const value"? - You should be able to write a simple example of overloading operator+ - Friend functions - Restrictions on operator overloading: - E.g., can't change precedence or associativity Dynamic Memory - Review of pointers: syntax ("*", "&", and "->") - "new" operator: - syntax for using "new" - What it returns (a pointer) - Where space is allocated from - "delete" operator: - syntax for using "delete" - type of argument (a pointer) - setting pointer to NULL after "delete" - What a "memory leak" is - How to allocate and delete arrays - How to allocate and delete 2-dimensional arrays - Destructors - Purpose of destructors - Syntax for declaring/defining a destructor for a class Copy Constructors, Assignment Operator - Why copy constructor is needed - to duplicate dynamically allocated members - Why is this very important? - Overloading operator= (assignment operator) - How to overload "=" - What operator= should return - Pitfalls of overloading operator= - self-assignment pitfall Inheritance - What "inheritance" is - Main motivation: reuse - "has a" vs. "is a" relationships between objects - Inheritance hierarchy - Base class vs. derived class - Also: superclass/subclass, parent class/child class - Syntax for defining a derived class - (Don't need to know any subclassing specification than "public") - How derived classes inherit member functions from base class - How "public", "private", and "protected" data and methods of base class can/cannot be accessed by derived classes - Constructors and destructors - not inherited! - When is parent class's constructor and destructor called? - Explicitly invoking parent class's non-default constructor - operator= and inheritance - Method overriding vs. overloading - same signature vs. different signatures (param lists) Polymorphism - What "polymorphism" means - Why it only makes sense for pointers - Pointer-to-base-class can point to derived class object - Pointer-to-derived-class CANNOT point to base class object - Static vs. dynamic binding - when each is done - examples of each - Keyword "virtual" - what does it do? - must you declare virtual method from parent as "virtual" again in child? - Advantages of virtual methods - "Pure virtual" methods - Abstract classes - Polymorphic functions - Why destructors should be virtual - CLone() method - meant to solve aggregation problem - why "Clone()" is indispensible Exceptions - What exceptions are - Why the exception mechanism is good for error-handling - clarity of code structure - layering, encapsulation - generation of exception condition decoupled from management - The try/throw/catch trio - "throw" - What "throw" does - What kinds of things you can "throw" - "try" and "catch" - how the "try" block works - how the "catch" blocks after a "try" block work. - what the "parameter" type for a catch block does - Multiple catch blocks after a throw - how C++ decides which catch block to invoke - creating an inhertance hierarchy for exception types - Throwing exceptions in nested functions - Re-throwing an exception - An exception class and its member methods and data - Declaring what exceptions types a function/method might throw - How to declare that it throws no errors, vs. it doesn't know what exceptions it might throw - Why exceptions are particularly useful in constructors - Exceptions, dynamic memory, and memory leaks (DON'T have to know about auto_ptrs) - Exception-safe code - weak guarantee/strong guarantee/no-throw guarantee Templates - Purpose of templates - Reusing code patterns and algorithms that work across many types (as long as type is known at time of use) - Some common examples (e.g.: swap, sort) - Function templates - Syntax for defining a templated function - Use of the "template type parameter" (the thing inside the "<...>" - Class templates - Syntax for defining a templated class - using a templated class - Templates with multiple type parameters - How templates are implemented - new version instantiated for each new type - different calls with same type parameter use same instantiation of the template - calls with different type params use different instantiations - if a template is not used, it is never really tested - Restrictions on types you can use a template with - type must support all functions and operators used inside template definition Standard Template Library (STL), Iterators - STL contains many templated classes and functions - Much of STL is used to define various container types - What a "container" is - Fundamental container types: - list - set, multiset, pair - map, multimap - Iterators - What iterators are - Why they are necessary - General model for all iterators: - Supports iteration over members by emulating a simple pointer - does this by overloading many pointer operators: - "*", "->", "++", "--", "==", "!=", "=" - Basic use: - declaring an iterator - using begin() and end() methods - moving to the next item - Should be able to write simple example: set mySet; set::iterator pos; for (pos = mySet.begin(); pos != mySet.end(); ++pos) { cout << *pos; }