C++ Structure is a collection of different data types under the same name_. _Those data elements mean roll no, marks are named as members of the structure. Structures in C++ are user-defined data types that are used to store a group of items of non-similar data types.

Suppose, you are given a task to store the academic information of a student and make a program for that. One thing you can do is, you can take different data types according to the requirements, as an array to store the marks, a string to take a name, int to take roll number, etc. In this case, there can be a problem, like accessing data. But what if you are given a method where you can store them all together?

C++ Structure Example

C++ allows us to create our own user-defined aggregate data types. An aggregate data type is a data type that groups multiple individual variables together. One of the simplest aggregate data types is the struct. A struct (short for structure) allows us to group variables of mixed data types together into a single unit.

You can think of a box, where inside it all your favorite foods are stored. The structure is also the same, inside it all our requirements are stored.

#c++ #c++ structure #structures in c++

C++ Structure Example | Structure in C++ Tutorial
4.05 GEEK