COURSE HOME C++ Programming

START HERE

Getting Started with C++

C++ is a powerful and widely used programming language that combines high-level abstraction with precise control over data and memory. This course introduces the core ideas of C++ through clear explanations, worked examples, and regular programming practice.

After an introduction to C++, we spend a full week on data types, variables, input and output, and arithmetic. We then study loops, branching statements, and functions before introducing objects and classes, class inheritance, and polymorphic public inheritance. Arrays, strings, references, and object initialization are introduced where they are needed. Six guided labs reinforce these topics, and the final two weeks are for review.

Lectures and labs focus on one core idea at a time. Students complete starter code, run simple tests, and explain their changes. Student information examples connect the object-oriented labs.

8 THEORY WEEKS · 6 LAB WEEKS · 2 REVIEW WEEKS

Course Schedule

Week Mode Topic Materials Assignments
1 Theory 1 Getting Started with C++ Assignment
2 Theory 2 Dealing with Data Assignment
3 Theory 3 Loops and Relational Expressions Assignment
4 Lab 1 Loops and Relational Expressions Assignment
5 Theory 4 Branching Statements and Logical Operators Assignment
6 Lab 2 Branching Statements and Logical Operators Assignment
7 Theory 5 Functions: C++’s Programming Modules Assignment
8 Lab 3 Functions Assignment
9 Theory 6 Objects and Classes Assignment
10 Lab 4 Objects and Classes Assignment
11 Theory 7 Class Inheritance Assignment
12 Lab 5 Class Inheritance Assignment
13 Theory 8 Polymorphic Public Inheritance Assignment
14 Lab 6 Polymorphic Public Inheritance Assignment
15 Review Review Assignment
16 Review Review Assignment
Weekly Learning Notes

Use these notes to prepare for each theory week and its class check. The six lab assignments remain short, guided exercises.

Week 1 — Getting Started with C++

  • Create, compile, and run a program. Read #include <iostream>, main(), std::cout, return, braces, and semicolons. Use std:: to identify names from the standard library.
  • Class check: change the message in Hello, World! and fix a missing semicolon. Learn to read the compiler's first error message.

Week 2 — Dealing with Data

  • Declare and initialize int, double, char, and bool variables. Distinguish initialization from assignment; introduce const and simple type conversions.
  • Use std::cin and std::cout, +, -, *, /, and %. Explain integer division, floating-point division, operator precedence, and compound assignment such as +=.
  • Class check: read two integers and print their sum. Compare 5 / 2 with 5 / 2.0. Predict 5 % 2. Use valid numeric input throughout these first exercises.

Week 3 — Loops and Relational Expressions

  • Trace for and while loops using initialization, a test condition, and an update. Use relational operators and ++; recognize the do while loop and its first execution before the test.
  • Introduce a one-dimensional array with three integers: initialization, indexes starting at 0, and valid bounds. Use a short for loop to read its elements.
  • Class check: trace the sum from 1 to 3 and explain why a loop for n = 0 does not run. Identify the valid indexes of int scores[3].

Week 5 — Branching Statements and Logical Operators

  • Use if, if else, and else if with relational operators and the logical operators &&, ||, and !. Distinguish == from = and explain short-circuit evaluation with a small example.
  • Read a simple switch statement and recognize break and continue. Class check: test a passing-score condition with 59 and 60; write a condition for a score from 0 to 100.

Week 7 — Functions: C++’s Programming Modules

  • Define, declare, and call a function. Distinguish formal arguments from actual arguments; trace passing by value, return values, and local scope.
  • Introduce a reference as another name for an existing variable. Compare passing an int by value with passing it by reference; recognize a const reference as read-only access through that reference.
  • Class check: write add(a, b), then predict whether changing an int formal argument changes the caller's variable. Revisit references in Week 13 with class objects.

Week 9 — Objects and Classes

  • First use std::string to store and print a name. Then define a class with data members and member functions; explain objects, public and private access, and the dot operator.
  • Use a constructor to set up an object. Compare initialization with assignment in the constructor body. Introduce member initialization lists and const member functions; trace when a local object's constructor and destructor run.
  • Class check: create two Student objects and call show() on each. Explain why changing one student's score leaves the other student's score unchanged.

Week 11 — Class Inheritance

  • Explain the is-a relationship, base and derived classes, and public inheritance. Access private base-class data through a public member function.
  • Read the supplied member initialization list: construct the base-class part first, then initialize derived data members. Class check: explain Person(studentName) and reuse getName() when displaying a Student.

Week 13 — Polymorphic Public Inheritance

  • Review references with const Person&. Explain why a reference can refer to a Student or Teacher without copying the object into a Person value.
  • Use a virtual function and override. Keep the function's const qualifier consistent. Trace which introduce() runs when it is called through a base-class reference.
  • Recognize the supplied virtual destructor and = default: the compiler supplies the destructor; virtual supports correct destruction through a base-class pointer. Class check: predict the Student and Teacher messages. This exercise uses local objects and references.

Weeks 15–16 — Review

Week 15 revisits data, loops, branching statements, and functions. Week 16 revisits objects and classes, inheritance, and virtual functions using the lab programs and short code-reading questions.

Textbook terminology: C++ Primer Plus, 6th Edition

Class tasks: Theory weeks use a short exit check; lab assignments include instructions, starter code, and submission requirements. Extra homework is assigned only when needed.

Grading

Here’s more information about the class grade:

Breakdown

Below is the breakdown of the class grade:

  • — 60%: Final Examination — open-book written examination.
  • — 40%: Continuous Assessment — attendance, class performance, assignments, and labs.

COURSE MATERIALS

Learning Resources

TEXTBOOK REFERENCE

C++ Primer Plus, 6th Edition

Course topics and C++ terminology follow Stephen Prata’s English edition.

View Textbook Contents
LOCAL ALIGNMENT

Chinese Course Materials

Local topic boundaries, examples and grading alignment.

MODERN EXAMPLES

PPP3 · LearnCpp · CS106L

Selected C++ explanations for containers, classes, streams and project organization.

Course boundary: move semantics, smart-pointer implementation, template metaprogramming and manual new/delete are not core requirements.