Look at the code below. When the Hen object is created, is a Nest and Egg created inside of it? Or are the structs independent apart from scope? It seems to be so when it is allowed to create an Egg object.
I've looked around on the web but have not been able to find information about nesting that explains this. I hope that someone in this forum could clarify or point me to a tutorial.
Seron
Code:// henegg.cpp // exercise 5.6 #include <iostream> using namespace std; struct Hen { struct Nest { struct Egg { void display(); }; void display(); }; void display(); }; void Hen::Nest::Egg::display() { cout << "Egg" << endl; } void Hen::Nest::display() { cout << "Nest" << endl; } void Hen::display() { cout << "Hen" << endl; } void main() { Hen h; Hen::Nest n; Hen::Nest::Egg e; h.display(); n.display(); e.display(); }