C++ Programming Free Online Course 2 (Structures in C++)
Structures in C++ We often come around situations where we need to store a group of data whether of similar data types or non-similar data types. We have seen Arrays in C++ which are used to store set of data of similar data types at contiguous memory locations. Unlike Arrays, Structures in C++ are user defined data types which are used to store group of items of non-similar data types. What is a structure? A structure is a user-defined data type in C/C++. A structure creates a data type that can be used to group items of possibly different types into a single type. Structures in C++ How to create a structure? The ‘struct’ keyword is used to create a structure. The general syntax to create a structure is as shown below: struct structureName{ member1; member2; member3; . . . memberN; }; Structures in C++ can contain two types of members: Data Member : These members are normal C++ variables. We ca...