static use for class inside the same class c++

Hi,
I believe the next code is wrong:

class Egg {
    Egg e;
    int i;
    Egg(int ii=0) : i(ii) {}
};

because you would end up with an endless definition (memory allocation) of Egg objects, thus int i.
Ok, so God Eckel proposes for a singleton:

class Egg {
    static Egg e;
    int i;
    Egg(int ii=0) : i(ii) {}
};
Egg Egg::e(47);

Does the static qualifier prevent from the memory allocation for the endless series of int i? I am not quite sure because any new Egg object (thus, int i) is in an inner scope (e.e...), even static says that all Egg objects share the same static memory for that member. ???
I understand that making the constructor private prevents the class user from creating any object, leaving us only with the shared static data member, previously defined by the class creator. Right?
Thanks for reading

You can think of static members like global variables. You get the same object in all contexts, even though it's inside a class.

Ok, so I understand from your answer that only one instance of Egg object is allocated in the program static memory area, even when an egg class object is a member of that class.
:wall:
ty

In truth, it is a global variable accessed with the funny name of Egg::e. You can choose whether global things are allowed to use it by whether you make it public.

static functions in a class work the same way... In truth they are global functions accessed via classname::function().

so it just avoids name clashes, associating it with a class, but it still is global.
yes right, i understand what you mean :), just one more thing,
if for instance there were two static members of different classes, both static int i, there woud also be two addresses in the program's static area. int Egg::i and int Shell::i.
In the case above, wouldnt it create a global Egg e, which also contains another global Egg e, Egg::egg::e?
Thanks a million, i can imagine how hard it is to explain this

Yes, they would be separate. Their names would be mangled so they don't overlap when the program is linked -- the same way all C++ variable and function names get mangled so they don't overlap, to allow overloading.

I suppose there would be an Egg:e.e inside ( not Egg::egg::e ) as well as Egg::e.e.e, and so forth. But they'd all be the same object -- not a different one. They're not really contained inside the class in the first place, so they don't nest. Just consider them globals with funny names.