www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - problem with pointers

reply bobef <bobef_member pathlink.com> writes:
I am writing a XML parser in D, because all the links with such libriraries are
dead. And I have the following problem. When I parse the tags I set parent to
each node (with pointer, basicly "something.parent=&somethingelse;"). When all
is done address of objects seems changed and I get Access Violation if I use
"node.parent". I tried to do the work with "cast(XMLnode*)somethingelse" instead
of "&somethingelse" but it doesnt work neither. I could't find documentation
about pointers in D and I'm stuck. Any ideas why is this?
Jan 15 2005
next sibling parent "Ben Hinkle" <ben.hinkle gmail.com> writes:
"bobef" <bobef_member pathlink.com> wrote in message 
news:csbh1t$2i0e$1 digitaldaemon.com...
I am writing a XML parser in D, because all the links with such libriraries 
are
 dead. And I have the following problem. When I parse the tags I set parent 
 to
 each node (with pointer, basicly "something.parent=&somethingelse;"). When 
 all
 is done address of objects seems changed and I get Access Violation if I 
 use
 "node.parent". I tried to do the work with "cast(XMLnode*)somethingelse" 
 instead
 of "&somethingelse" but it doesnt work neither. I could't find 
 documentation
 about pointers in D and I'm stuck. Any ideas why is this?

Assuming your nodes are class objects and not structs it will work if you remove the &. Class objects in D have reference semantics (like Java, unlike C++) so using & takes the address of the reference not the object itself. -Ben
Jan 15 2005
prev sibling next sibling parent "Manfred Nowak" <svv1999 hotmail.com> writes:
bobef wrote:
[...]
 I get Access Violation if I use "node.parent".

Seems that you want to use "node.parent*". -manfred
Jan 15 2005
prev sibling parent "Miguel Ferreira Simões" <Kobold netcabo.pt> writes:
Try this! (I hope it works... I am no longer using this version)
I am going to re-design it soon.

Miguel Ferreira Simoes 
Jan 15 2005