www.digitalmars.com         C & C++   DMDScript  

D - inner classes

reply "Phill" <phill pacific.net.au> writes:
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
Apr 03 2004
parent reply Matthias Becker <Matthias_member pathlink.com> writes:
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!!!
Apr 04 2004
parent reply "Phill" <phill pacific.net.au> writes:
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

 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
Apr 04 2004
parent reply "Phill" <phill pacific.net.au> writes:
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
Apr 04 2004
parent reply "Ivan Senji" <ivan.senji public.srce.hr> writes:
"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

 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!
Apr 04 2004
next sibling parent reply Ant <duitoolkit yahoo.ca> writes:
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

 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
Apr 04 2004
next sibling parent reply "Ivan Senji" <ivan.senji public.srce.hr> writes:
"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

 an instance of its enclosing class and has direct access to the



 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


 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

Apr 04 2004
parent Ant <duitoolkit yahoo.ca> writes:
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

 an instance of its enclosing class and has direct access to the



 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


 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
Apr 04 2004
prev sibling parent reply "Manfred Nowak" <svv1999 hotmail.com> writes:
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!
Apr 04 2004
parent Ant <duitoolkit yahoo.ca> writes:
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
Apr 04 2004
prev sibling parent "Phill" <phill pacific.net.au> writes:
I just do this(as im sure a lot of other people do)

---------------------
class outer
{
 char[] test = "hi there";
 this()
 {
  new inner("outer");
  }

class inner : Frame
{
 this(char[] str)
 {
  outer o;
  printf(o.test);
  }

 }//end inner

}//end outer

You can do exactly the same with methods ie:

outer o;
o.doIt();


Phill.

"Ivan Senji" <ivan.senji public.srce.hr> wrote in message
news:c4p7bv$bi$1 digitaldaemon.com...
 "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

 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

 is
 called inner class. It would solve a big design problem in one of my
 projects!

--- 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
Apr 04 2004