Can anyone explain me what is struct in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can anyone explain me what is struct in c++?

I have attached a code here. please someone explain me this. I dont know what is struct! https://code.sololearn.com/cffbq5Df14US/?ref=app

30th May 2018, 8:44 AM
Sneha Johnson
6 Answers
+ 2
YOU ARE CREATING TWO NEW DATA TYPES A AND B. AND USING THIS DATA TYPES YOU HAVE CREATED TWO VARIABLES NAME a AND b IN STRUCT C. NOW C IS NEW DATA TYPE AND USING THIS YOU HAVE CREATED C1 AND C2 NAMED VARIABLE AND ASSIGN VALUE. C1=1,2,3,4 MEANS a.a=1 a.b=2 b.b=3 b.a=4 SAME GOES WITH C2 LASTLY YOU PRINT C1.b.a means 4 AND SAME GOES WITH C2 I KNOW IT'S BIT COMPLICATED.
30th May 2018, 12:03 PM
Meet Mehta
Meet Mehta - avatar
+ 4
STRUCT MEANS STRUCTURE. YOU CAN GROUP RELATIVE DATA OF ANY DATA TYPE AND DECLARE IT USING STRUCT. CONSIDER FOLLOWING EG : IF YOU WANT TO CREATE A PROGRAM WHICH INCLUDE DETAILS OF STUDENTS RESULT (NAME , CLASS , MARKS ,ETC) YOU CAN GROUP IT INSTEAD OF DECLARING VARIABLE SEPERATELY.
30th May 2018, 8:57 AM
Meet Mehta
Meet Mehta - avatar
+ 4
ARRAYS ARE USED TO GROUP VARIABLES OF SAME DATA TYPES. WHEREAS STRUCTURE IS USED TO GROUP LOGICALLY RELATED DATA OF DIFFERENT DATA TYPE.
30th May 2018, 9:27 AM
Meet Mehta
Meet Mehta - avatar
+ 3
Structs are what can have some variables and functions.The difference from classes is that the default access specific is public.
30th May 2018, 8:58 AM
Disvolviĝo;
Disvolviĝo; - avatar
+ 1
Thank you so much MEET MEHTA ... yes it is complicated. so hard to understand!
30th May 2018, 4:39 PM
Sneha Johnson
0
can you explain me the program?
30th May 2018, 11:24 AM
Sneha Johnson