Array of Structures
Let's explore how to define an array of structures in C++.
We'll cover the following
Introduction
We have 100 students in a class, and we have to store the name
, age
, and roll_number
of each student, which means we need 300 variables. We have found a way to store all these variables under a single name.
However, to store data for each student in the class, we still have to declare 100 structure variables. Declaring 100 structure variables and then keeping track of them is quite difficult.
Here, an array of structures comes in handy!
In C++, each element of a structure array represents a structure variable.
Get hands-on with 1400+ tech skills courses.