// demonstrates use of substructures // Mikhail Nesterenko // 10/14/2009 #include #include using std::cout; using std::endl; using std::string; // example structure struct example{ int a; string b; }; // second example structure whose member is a substructure struct compExample{ int d; example e; }; int main(){ compExample ce1; ce1.d=1; // accessing basic type member // accessing members of the substructure ce1.e.a=2; ce1.e.b="two"; compExample ce2; ce2 = ce1; // copying of the members // accessing copied members of the substructure cout << "ce2.e.a=" << ce2.e.a << endl; cout << "ce2.e.b=" << ce2.e.b << endl; }