CS106L

Optional & Type Safety

0 points

Attendancefor this activity has closed. Sign in to be counted — nothing is recorded while you are signed out, and the activity itself works either way.

An Optional Is Not an Integer

A wraps a value that might be absent. Consider this code:

1std::optional<int> attempts = 3;2std::cout << attempts + 1;

Will it compile? What should we do if attempts might be empty?

What is the problem with this code?

0 of 1 done