+ 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
6 Antworten
+ 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.
+ 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.
+ 4
ARRAYS ARE USED TO GROUP VARIABLES OF SAME DATA TYPES.
WHEREAS STRUCTURE IS USED TO GROUP LOGICALLY RELATED DATA OF DIFFERENT DATA TYPE.
+ 3
Structs are what can have some variables and functions.The difference from classes is that the default access specific is public.
+ 1
Thank you so much MEET MEHTA ... yes it is complicated. so hard to understand!
0
can you explain me the program?