Код: Выделить всё
struct name { // datatype "name" is visible everywhere
string first ;
string midinits ;
string family ;
};
struct people {
int numero;
name nom;
};
/* OR with the sub-structure nested in the parent before defining a variable name for the structure. */
struct people { // define the structure
int numero; // add an integer member
struct name { // define a substructure "name" - datatype "name" is valid
// ONLY within a people structure.
string first ; // add members to substructure "name"
string midinits ;
string family ;
};
name nom; // Now you need to add a variable, nom, of type N
// to the "people" structure.
};
// Manually build and print two "people" type variables - me and you.
people me;
people you;
me.numero = 1;
me.nom.first = "Billy";
me.nom.midinits = "B";
me.nom.family = "Blogs";
you.numero = 2;
you.nom.first = "Freddy";
you.nom.midinits = "F";
you.nom.family = "Nurks";
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79154171/i-needed-help-creating-nested-structures-as-i-began-my-learning-with-c-i-foun[/url]