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

Loading...

Friend's some reason we need some long time for next update, Sorry For Long Time, see you soon.

We make a Collaboration with HackIsOn YouTube Channel So, Please Subscribe Their Channel and keep supporting