C++ Interview Question

What is the difference between a vector and an array in C++?

Updated 2026-07-10 · Beginner friendly
Quick answer

A raw array has a fixed size set at compile time and does not know its own length. A std vector is a dynamic array that can grow and shrink at run time, tracks its size, and manages its own memory. Vectors are safer and more flexible, so they are the default choice, while raw arrays are used only for simple fixed size or low level cases.

Quick comparison

#include <vector>
std::vector<int> v;
v.push_back(1);      // grows automatically
int arr[3] = {1,2,3}; // fixed size, cannot grow
In the interview

Say prefer std vector in modern C++ because it manages memory and size for you, and use raw arrays only when you must. That practical stance matches how experienced C++ developers actually code.

Want the full C++ guide?

Read every C++ concept with notes, diagrams, and code in one place. Track your progress as you go.

Open the C++ guide All C++ questions