Nested Structures in C++ :

Nested Structure :

When a structure contains another structure, it is called nested structure. A structure consisting of such complex elements is called a complex structure.

Example :

  1. /* Description: store data use nested structure in C++ language */
  2. #include<iostream>
  3. using namespace std;
  4. struct name{
  5. char name[20];
  6. };
  7. struct roll{
  8. char name[20];
  9. struct name info;
  10. }data;
  11. int main()
  12. {
  13. cout<<"Enter student name: ";
  14. cin>>;
  15. cout<<"Enter student Roll: ";
  16. cin>>data.roll;
  17. cout<<"\n\n---Data Store Completed---\n\n";
  18. cout<<"Name : "<< <<"\nRoll: "<<data.roll;
  19. }

Output :

C++ language store data use nested structure

Arrays of Structures :

Since an array can contain similar elements, the combination having structures within an array is an array of structures. For instance, to store addresses of 100 members of the council, you need to create an array (creates 100 sets of variables).

addr mem_addr[100];

Computer Science Engineering

Special Notes

It's a special area where you can find special questions and answers for CSE students or IT professionals. Also, In this section, we try to explain a topic in a very deep way.

CSE Notes