Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
April 20, 2004 binary tree? | ||||
---|---|---|---|---|
| ||||
hrmm can i make a binary tree with D? seems it doesnt like having a pointer to a class inside a class? eg: Node { Node pointer; } is this possible yet with D? |
April 20, 2004 Re: binary tree? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Fabian | Fabian wrote: > hrmm can i make a binary tree with D? > seems it doesnt like having a pointer to a class inside a class? > > eg: > > Node > { > Node pointer; > } Have you written a complete program that shows how it doesn't like this yet? Have you tried compiling it yet? Have you come up with an exact error message yet? > is this possible yet with D? Yes, as far as I know. Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit. |
April 20, 2004 Re: binary tree? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Fabian | I've used this... for example, some code from a database converter I semi-recently wrote:
------------------------------
// . . . some junk
class DBObj {
// . . . some junk
DBObj parent,
children,
children_next,
location,
contents,
contents_next;
// . . . some junk
}
------------------------------
So I must not understand what the problem is...
-C. Sauls
-Invironz
Fabian wrote:
> hrmm can i make a binary tree with D?
> seems it doesnt like having a pointer to a class inside a class?
>
> eg:
>
> Node
> {
> Node pointer;
> }
>
> is this possible yet with D?
|
April 20, 2004 Re: binary tree? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Fabian | Fabian wrote: > hrmm can i make a binary tree with D? > seems it doesnt like having a pointer to a class inside a class? > > eg: > > Node > { > Node pointer; > } > > is this possible yet with D? > > What you are trying is _NOT_ possible. "Node" should be "class Node" or "struct Node" Then it should work Have a look at my dlinked list at http://d.wienczny.de |
April 20, 2004 Re: binary tree? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | Huh? I do see a minor syntax error...but the code is basically valid. You can do this:
class Node {
Node pointer; // this is a reference to a class object
};
or this:
struct Node {
Node *pointer;
};
Russ
Stephan Wienczny wrote:
> Fabian wrote:
>
>> hrmm can i make a binary tree with D?
>> seems it doesnt like having a pointer to a class inside a class?
>>
>> eg:
>>
>> Node
>> {
>> Node pointer;
>> }
>>
>> is this possible yet with D?
>>
>>
>
> What you are trying is _NOT_ possible.
>
> "Node" should be "class Node" or "struct Node"
> Then it should work
> Have a look at my dlinked list at http://d.wienczny.de
|
Copyright © 1999-2021 by the D Language Foundation