Nested Structs
Steven Schveighoffer
schveiguy at yahoo.com
Mon Dec 27 10:57:13 PST 2010
On Mon, 27 Dec 2010 12:50:47 -0500, bearophile <bearophileHUGS at lycos.com>
wrote:
> Steven Schveighoffer:
>
>> A struct nested in a class does not have a hidden "outer" pointer as a
>> nested class does.
>
> But I think this will eventually change, once this part is implemented:
> http://www.digitalmars.com/d/2.0/struct.html
>
>> Nested Structs: A nested struct is a struct that is declared inside the
>> scope of a function or a templated struct that has aliases to local
>> functions as a template argument. Nested structs have member functions.
>> It has access to the context of its enclosing scope (via an added
>> hidden field).<
That is implemented, but notice the conditions that form a nested struct
do not include "inside a class" or "inside a struct" (that "templated
struct that has aliases to local functions as a template argument"
condition is pretty specific, I'm talking about just putting it in any old
struct).
This is decidedly different from a nested class:
http://www.digitalmars.com/d/2.0/class.html#nested
"A nested class is a class that is declared inside the scope of a function
or another class. A nested class has access to the variables and other
symbols of the classes and functions it is nested inside"
This is what the OP was desiring.
-Steve
More information about the Digitalmars-d-learn
mailing list