PIC 10B: Intermediate Programming
About
In this C++ course, students learn how to manage memory on the heap and how to implement data structures like linked lists and binary search trees together with their iterators. Many useful aspects of the C++ language are covered such as operator overloading, and copy and move semantics.
Course Description
Lecture, three hours; discussion, one hour. Object oriented programming in C++; operator overloading; memory management, copy and move constructors, copy and move assignment operators, destructors; iterators; data structures and their implementation, linked lists, binary search trees; inheritance and polymorphism; recursion, algorithms for sorting and searching. P/NP or letter grading.
Learning Outcomes / Course Objectives / Core Competencies
Incoming students should be able to...
- Analyze short programs involving control flow and functions to determine what the code is doing, to identify any errors the code has, and to correct the errors that are found.
- Create short classes from scratch.
After successful completion of PIC 10B, students should be able to...
- Define arithmetic operators which imitate the corresponding operations for fundamental types.
- Choose the most appropriate or correct function signature when overloading operators and articulate the consequences of using an incorrect signature.
- Implement, test, and debug constructors, assignment operators, and destructors which manage memory on the heap.
- Examine code to identify the source of a memory leak and modify the code to fix the memory leak.
- Explain the difference between a shallow copy and a deep copy and identify the errors that result in code that performs a shallow copy unintentionally.
- Explain the efficiency gains that move semantics accomplish by correctly recording the number of times data is copied in code that uses copy and move constructors and assignments.
- Predict the output of code involving constructors, assignment operators, and destructors which identify themselves with print statements.
- Implement linked list and binary search tree classes when provided with their class interfaces.
- Implement iterators for a class that does not store pointers specifically for the next elements, e.g. a binary search tree.
- Recognize and explain when inheritance is an appropriate tool to use for two related classes.
- Predict the output of code that uses polymorphism, virtual member functions, and non-virtual member functions.
- Implement, test, and debug simple recursive functions.
- Recall algorithms for sorting and searching.
General Course Outline / Schedule of Lectures
At least four lectures should be dedicated to each of the following major topics. Instructors are encouraged to spent longer on efficient memory management and operator overloading in order to explain copy constructors, move constructors, copy assignment operators, move assignment operators, and destructors sufficiently.
efficient memory management
- stack and heap
- pointers, new and delete expressions, memory leaks, RAII
- lvalue and rvalue references, copy and move constructors, destructors
operator overloading
- binary vs unary, member vs non-member distinctions
- comparison operators, arithmetic operators, prefix and postfix ++ and --
- operator<<, operator>>, subscript, call, and conversion operators
- this and friend keywords
- assignment operator (copy, move, copy and swap idiom)
data structures
- implementing linked lists and binary search trees with iterators
- implementing other structures of the instructor's choice
- some containers available in the standard library
inheritance and polymorphism (single inheritance cases only)
- virtual, override, protected keywords
- polymorphism for pointers and references
- slicing, up and down-casting, dynamic casts
recursion
- sorting algorithms
- searching algorithms
- algorithm complexity and big-O notation
Expected Grade Scheme and Homework Assignments
- Homework: 15%
- Midterm 1: 25%
- Midterm 2: 25%
- Final: 35%
PIC 10B instructors are required to assign at least four homework assignments.