Since these students already understand the "how" of programming (logic, loops, and collections) through Python, this curriculum focuses on the "why"—specifically how C++ handles memory, types, and the compilation process.
The goal is to transition them from Python's abstraction to C++'s precision.
C++ for Pythonistas: Curriculum Outline
- High-level vs. Low-level: What happened to the Interpreter?
- The Build Cycle: Source -> Compiler -> Object -> Linker.
- Boilerplate Breakdown: Header files and
int main().
- Static vs. Dynamic Typing.
- Integral Types:
int,long,short, and theunsignedmodifier. - Floating Point Precision:
floatvsdouble. - Character encoding:
charvs Python's string-index.
- The
iostreamlibrary. - Standard Output (
cout) and Insertion Operators (<<). - Standard Input (
cin) and the Buffer. - Formatting output with
iomanip.
- Boolean logic differences (no more
and/or, welcome&&/||). - Braces
{}vs. Indentation. - The
switchstatement: A new tool for branching.
- The
&operator: Finding where data lives. - Pass-by-value vs. Pass-by-reference.
- Why C++ doesn't "copy" everything by default.
- Static Arrays: Memory allocation at compile time.
std::vector: The closest relative to the Python List.- Common pitfalls: Out-of-bounds errors and "Segfaults."
- C-style strings (null terminators) vs.
std::string. - String manipulation and the
stringlibrary.
- Function Prototypes (Forward Declaration).
- Return types and the
voidkeyword. - Overloading: Multiple functions with the same name.
- Grouping related data (Intro to OOP).
- Transitioning from Python Dictionaries to C++ Structs.
- The
*operator: Holding addresses. - Null pointers (
nullptr). - Introduction to the Heap vs. the Stack.
- Classes and Objects.
- Access Specifiers:
publicvsprivate. - Constructors and Destructors (Managing cleanup).
Why this structure works:
- Front-loading Memory: Python hides memory management. By introducing references and types early, students understand why C++ feels "stricter."
- Vector focus: Since they know Python lists, teaching
std::vectorearly gives them a sense of productivity before they dive into the "scarier" world of raw pointers. - Header Files: This is usually the biggest hurdle for Python students. Dedicating the first chapter to the build process prevents "magic code" syndrome.
Would you like me to expand on the specific exercises or "Python vs. C++" comparison charts for any of these chapters?