[Tree-hh] Fwd: Re: Help needed with a copy constructor.

stefankoshiw306 at gmail.com stefankoshiw306 at gmail.com
Sat Dec 12 18:25:35 GMT 2009


---------- Forwarded message ----------
From: Stefan Koshiw <stefankoshiw306 at gmail.com>
Date: Dec 11, 2009 1:12pm
Subject: Re: [Tree-hh] Help needed with a copy constructor.
To: ree-hh at projects.hepforge.org
CC: Kasper Peeters <kasper.peeters at durham.ac.uk>


> Hi Kasper,

> Thank you for your help. Could you give me an example of how i would use  
> the Iterator copy constructor?
> I need to keep the iterators scope class wide and private. I tried  
> various different combinations with the iterators defined as pointers,  
> but i couldn't get them to work. Is there a way to use the iterator copy  
> constructor without declaring the iterators as pointers?



> tree::iterator *LSystem;

> LSystem = new tree::iterator(*p_Thing.ITERGetLSystem());
> or
> LSystem = (p_Thing.ITERGetLSystem());

> tree::iterator* thing::ITERGetLSystem(void) const { return LSystem; }



> Thank you


> Stefan



> 2009/12/4 Kasper Peeters kasper.peeters at durham.ac.uk>

> > Thank you for that, it does work, in that it copies the tree root




> It copies the entire tree, not just the root.



> > it doesn't copy the value of the node iterators.




> It cannot; when you copy one std::vector to another, you also do not

> magically get a new set of iterators pointing to the second vector.



> > THEREFORE... Is it possible to search a tree to find its nodes?




> You can use the 'find' member, or you can just walk all nodes and act

> when required. (I probably don't understand the question).



> Cheers,

> Kasper




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.hepforge.org/lists-archive/tree-hh/attachments/20091212/4a6b76b2/attachment.htm 


More information about the Tree-hh mailing list