Functions and everyday data

Splitting programs into functions, passing data efficiently with references, and working with text, lists and memory.

About 14 hours of study

Learning objectives

Lessons

  1. 1

    Functions in C++

    Write functions with parameters and return values, give parameters default values, and overload one name for different types.

  2. 2

    References Intermediate

    Give a variable a second name, let functions change their caller's variables, and pass large values without copying them.

  3. 3

    The string class

    Work with std::string: length, characters, joining, searching and cutting, and pulling words apart with string streams.

  4. 4

    Vectors

    Store lists that grow with std::vector: adding and removing items, looping safely, sorting, and two-dimensional tables.

  5. 5

    Pointers and memory Intermediate

    Addresses and pointers, nullptr, new and delete, and why modern C++ usually lets containers manage memory for you.

Module practice

Module quiz

1. When two functions share a name and differ in their parameters, what is this called?
2. void f(int& n) { n = 5; } After int a = 1; f(a); what is a?
3. What is the best parameter for a long vector that is only read?
4. What is the difference between v[i] and v.at(i)?
5. What does s.find("x") return when x is not present?
6. Which pair matches correctly?

‹ FoundationsYour own types and the standard library ›