+ 4
Can any one explain me what is structure in c++ in a simple way?
Please Explain structure in a simple way.
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.
+ 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
+ 1
Thank you guys
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;
};
0
Thank you Deepak
0
здравстуйте есть русские^^"
0
Анна Меджик😋 допустим есть те кто знают русский язык, но мне кажется что этот вопрос тут не к месту.
0
Hi Vasile
I am sorry but
I don't know in which language you have written the Answer......
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.
0
Ok.... Thanks Mark