Please enable JavaScript to use CodeHS

Data Structures in C++

Lesson 4.1 2D Vectors

Description

In this lesson, students learn about two-dimensional (2D) vectors, a data structure that stores elements in a grid-like arrangement of “rows” and “columns.” Every element of a 2D vector is a vector, similar to how every element of a 2D array is an array.


Objective

Students will be able to:

  • declare and initialize a 2D vector
  • access and modify elements of a 2D vector
  • iterate through a 2D vector using a for and for-each loop
  • utilize 2D vectors to solve real-world problems