+ 4

Can any one explain me what is structure in c++ in a simple way?

Please Explain structure in a simple way.

12th Sep 2018, 3:42 PM
Max Vhanamane
Max Vhanamane - avatar
10 Réponses
+ 3
Hi Mhalappa Vhanamane, As I think you know, C/C++ has many primitives types, e.g., int, float, double, char, etc. But it does not have composed types, for example, the "pair" type containing a int and a double. Structures allow you to create such new types. Let's see how to create the Pair type: typedef struct{ int i; double x; }Pair; Now you can declare variables with this type: Pair var; and access its members: var.i = 1; var.x = 3.14; You can abstract this concept and use your imagination to create very complex types.
12th Sep 2018, 6:30 PM
Mark
+ 1
look to your ID ...you can see many fields Name,Age.... all in your ID so, ID is your structure name , and all fields are your ID fields. in same way C++ use one name as structure name with many different type of variables at that structure... for more details to understand C++ structure and how can help you in programming visit link below : https://www.programiz.com/cpp-programming/structure
12th Sep 2018, 6:20 PM
Ahmed Bahaddin
Ahmed Bahaddin - avatar
+ 1
Thank you guys
12th Sep 2018, 7:33 PM
Max Vhanamane
Max Vhanamane - avatar
0
A struct in the C programming language (and many derivatives) is a composite data type (or record) declaration that defines a physically grouped list of variables to be placed under one name in a block of memory, allowing the different variables to be accessed via a single pointer, or the struct declared name which . he general syntax for a struct declaration in C is: struct tag_name { type member; type member; /* declare as many members as desired, but the entire structure size must be known to the compiler. */ }; struct account { int account_number; char *first_name; char *last_name; float balance; };
13th Sep 2018, 1:40 PM
deepak sharma
deepak sharma - avatar
0
Thank you Deepak
13th Sep 2018, 2:14 PM
Max Vhanamane
Max Vhanamane - avatar
0
здравстуйте есть русские^^"
13th Sep 2018, 6:48 PM
Анна Меджик😋
0
Анна Меджик😋 допустим есть те кто знают русский язык, но мне кажется что этот вопрос тут не к месту.
14th Sep 2018, 4:22 AM
Vasile Eftodii
Vasile Eftodii - avatar
0
Hi Vasile I am sorry but I don't know in which language you have written the Answer......
14th Sep 2018, 4:41 AM
Max Vhanamane
Max Vhanamane - avatar
0
Max Vhanamane, he wrote in Russian. But don't worry that is not a reply to your question. He is just talking to Anna that wrote the post above his.
14th Sep 2018, 9:04 AM
Mark
0
Ok.... Thanks Mark
14th Sep 2018, 6:46 PM
Max Vhanamane
Max Vhanamane - avatar