Jump to page: 1 2
Thread overview
inner classes
Apr 03, 2004
Phill
Apr 04, 2004
Matthias Becker
Apr 04, 2004
Phill
Apr 04, 2004
Phill
Apr 04, 2004
Ivan Senji
Apr 04, 2004
Ant
Apr 04, 2004
Ivan Senji
Apr 04, 2004
Ant
Apr 05, 2004
Manfred Nowak
Apr 05, 2004
Ant
Apr 05, 2004
Phill
April 03, 2004
Is this URL not up to date?

http://www.digitalmars.com/d/comparison.html

I noticed that it states that D doesnt have
inner classes, but as you know it does.

Phill.




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.648 / Virus Database: 415 - Release Date: 3/31/2004


April 04, 2004
>Is this URL not up to date?
>
>http://www.digitalmars.com/d/comparison.html
>
>I noticed that it states that D doesnt have
>inner classes, but as you know it does.

It does? I didn't know about it. Thanks for telling me. Or do you mix it up with nested classes? Nested classes != inner classes!!!


April 04, 2004
The difference seems to be a bit blurred to me,
after reading this quote from this URL:
========================
Like other members, a nested class can be declared static (or not). A static
nested class is called just that: a static nested class. A nonstatic nested
class is called an inner class. These are illustrated in the following code:

class EnclosingClass{
    . . .
    static class AStaticNestedClass {
        . . .
    }
    class InnerClass {
        . . .
    }
}
===================================
http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html

Phill.


"Matthias Becker" <Matthias_member@pathlink.com> wrote in message news:c4ofkm$21ld$1@digitaldaemon.com...
> >Is this URL not up to date?
> >
> >http://www.digitalmars.com/d/comparison.html
> >
> >I noticed that it states that D doesnt have
> >inner classes, but as you know it does.
>
> It does? I didn't know about it. Thanks for telling me. Or do you mix it
up with
> nested classes? Nested classes != inner classes!!!
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.648 / Virus Database: 415 - Release Date: 3/31/2004


April 04, 2004
But then again:

 Definition:  An inner class is a nested class whose instance exists within
an instance of its enclosing class and has direct access to the instance
members of its enclosing instance.

So it is clearly not an Inner class that D has.....

Phill.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.648 / Virus Database: 415 - Release Date: 3/31/2004


April 04, 2004
"Phill" <phill@pacific.net.au> wrote in message news:c4ogmn$22un$1@digitaldaemon.com...
> But then again:
>
>  Definition:  An inner class is a nested class whose instance exists
within
> an instance of its enclosing class and has direct access to the instance members of its enclosing instance.
>
> So it is clearly not an Inner class that D has.....

I was thinking about how great would it be to have that but i didn't know it
is
called inner class. It would solve a big design problem in one of my
projects!


April 04, 2004
On Sun, 04 Apr 2004 16:50:53 +0200, Ivan Senji wrote:

> "Phill" <phill@pacific.net.au> wrote in message news:c4ogmn$22un$1@digitaldaemon.com...
>> But then again:
>>
>>  Definition:  An inner class is a nested class whose instance exists
> within
>> an instance of its enclosing class and has direct access to the instance members of its enclosing instance.
>>
>> So it is clearly not an Inner class that D has.....
> 
> I was thinking about how great would it be to have that but i didn't know it
> is
> called inner class. It would solve a big design problem in one of my
> projects!

I don't know why we don't have them.

for your design problems just pass a pointer of the
outer (nesting?) class to the nested class
I do it all the time.

I can't believe that it would be any problem at all to add inner classes to the language.

Ant

April 04, 2004
"Ant" <duitoolkit@yahoo.ca> wrote in message news:pan.2004.04.04.14.00.38.516985@yahoo.ca...
> On Sun, 04 Apr 2004 16:50:53 +0200, Ivan Senji wrote:
>
> > "Phill" <phill@pacific.net.au> wrote in message news:c4ogmn$22un$1@digitaldaemon.com...
> >> But then again:
> >>
> >>  Definition:  An inner class is a nested class whose instance exists
> > within
> >> an instance of its enclosing class and has direct access to the
instance
> >> members of its enclosing instance.
> >>
> >> So it is clearly not an Inner class that D has.....
> >
> > I was thinking about how great would it be to have that but i didn't
know it
> > is
> > called inner class. It would solve a big design problem in one of my
> > projects!
>
> I don't know why we don't have them.
>
> for your design problems just pass a pointer of the
> outer (nesting?) class to the nested class
> I do it all the time.

I would do it too but i have some really small classes (not so many data) and the inner classes solution would be much nicer.

> I can't believe that it would be any problem at all to
> add inner classes to the language.
>
> Ant
>


April 04, 2004
On Sun, 04 Apr 2004 22:26:52 +0200, Ivan Senji wrote:

> "Ant" <duitoolkit@yahoo.ca> wrote in message news:pan.2004.04.04.14.00.38.516985@yahoo.ca...
>> On Sun, 04 Apr 2004 16:50:53 +0200, Ivan Senji wrote:
>>
>> > "Phill" <phill@pacific.net.au> wrote in message news:c4ogmn$22un$1@digitaldaemon.com...
>> >> But then again:
>> >>
>> >>  Definition:  An inner class is a nested class whose instance exists
>> > within
>> >> an instance of its enclosing class and has direct access to the
> instance
>> >> members of its enclosing instance.
>> >>
>> >> So it is clearly not an Inner class that D has.....
>> >
>> > I was thinking about how great would it be to have that but i didn't
> know it
>> > is
>> > called inner class. It would solve a big design problem in one of my
>> > projects!
>>
>> I don't know why we don't have them.
>>
>> for your design problems just pass a pointer of the
>> outer (nesting?) class to the nested class
>> I do it all the time.
> 
> I would do it too but i have some really small classes (not so many data) and the inner classes solution would be much nicer.
> 

We agree. I do that with nested classes,
and the nested class is a friend of the outer class
so it has access to all it's members.

this compiles and runs as expected:

public class A
{
	private int a;

	this()
	{
		new B(this);
	}

	private class B
	{
		int a;
		this(A outerClassThatIsAFriend)
		{
			outerClassThatIsAFriend.a = 1;
			a = 23;
			printf("B.this outerClassThatIsAFriend.a = %d\n", outerClassThatIsAFriend.a);
			printf("B.this a = %d\n", a);
		}
	}
}

int main(char[][] args)
{
	new A;
	return 0;
}




Ant

April 05, 2004
Ant wrote:
> I don't know why we don't have them.
[...]

What is the difference between an inner class and a nested class which is derived from its enclosing class?

So long!



April 05, 2004
On Mon, 05 Apr 2004 04:24:57 +0200, Manfred Nowak wrote:

> 
> Ant wrote:
>> I don't know why we don't have them.
> [...]
> 
> What is the difference between an inner class and a nested class which is derived from its enclosing class?
> 
> So long!

you only have one enclosing instance for all the inners you instanciate.

Ant

« First   ‹ Prev
1 2