Structures in C++ :

Introduction to Structures in C++ language :

C language Structure (.) Operator or sizeof() - Structures are one of the two important building blocks in the understanding of classes and objects. A structure is a collection of data while a class is a collection of data and functions. In other words, we can say, a structure plus related functions make a class. Technically, there is no difference between a structure and a class. The keyword struct tells the compiler that a structure is begin defined.

Example :

  1. /* Description: store students name in C++ language */
  2. #include<iostream>
  3. using namespace std;
  4. struct data{
  5. char name[20];
  6. }info[21];
  7. int main()
  8. {
  9. int i,j;
  10. cout<<" Enter how many student data you want to load ( MAX 20 ): ";
  11. cin>>i;
  12. for(j=1;j<=i;j++)
  13. {
  14. cout<<"\n No. "<&l<j <<" Student name : ";
  15. cin>>info[j].name;
  16. }
  17. cout<< "\n ------ DATA STOR COMPLETED ------- \n\n";
  18. for(j=1;j<=i;j++)
  19. {
  20. cout<<"\n No. "<&l<j <<" Name: " <<info[j].name;
  21. }
  22. }

Output :

C++ language store students name

Next Update


We create a new YouTube channel (NightHawk) for gaming purpose like online games streaming or games review.

We need some time for make video tutorials (CodeX) so, stay with us and keep supporting and you know already we make a Collaboration with HackIsOn YouTube channel long time ago So, please Subscribe Our Channels

Protection died IPs active, this IP range is not allowed !