StudyGraph
Procedural Programming with C++ Explainer

How C++ Stores a 2D Array in Memory

A 2D array in C++ is really one long row in memory.

Lesson notes

Key points

Takeaway: 2D arrays are stored row by row; columns fix the layout.

Quick check: Why must int m[][3] keep the 3 in a parameter?
  1. To compute element offsets
  2. To limit the number of rows
  3. To stop pass by value

2D arrayRow-major orderIndex formulaColumn size required

Lessons like this, for your syllabus.

Short narrated study videos written for your course, level and exam. Free to start.

Get lessons for your own syllabus