Add a reserved seat
Before you start this master track
Typed functions and collections. Be ready to reason about references, aliasing, and iterators.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Predict the result.
What final seat and vector size are printed?
#include <iostream>#include <string>#include <vector>int main() { std::vector<std::string> seats = {"A1", "B2"}; seats.push_back("C4"); std::cout << seats.back() << " / " << seats.size() << '\n';}Each example is a complete C++17 console program with its own main function and required standard-library headers. Compile and run one mission at a time.
Review the lesson
A vector stores a sequence and can grow when another element is added. The string element type keeps each seat label as text. push_back appends a seat after the existing entries. back reads the last entry, while size reports how many entries the vector currently contains.