Discussion: Copying void *?
Afficher un message
Vieux 21/02/2008, 23h15   #2
Victor Bazarov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Copying void *?

Travis wrote:
> So I had a Tree (custom written) that had, as a node type, as pretty
> simple class. The class just stored some std::string's plus a void*.
>
> So my tree instantiation use to be Tree <myClass *> myTree so adding a
> new looked something like
>
> myTree.Insert( new myClass( "string 1", "string 2", (void*) 2) ); //
> seemed to work fine
>
> Then I decided it was silly to store a tree of pionters, and changed
> the tree to Tree <myClass> myTree so adding looked more like...
>
> myTree.Insert( myClass( "string 1", "string 2", (void*) 2) ); //
> crashes?
>
> This insertion style compiles but the later one it crashes and I'm not
> sure why. It would *appear* that the void* at some point goes NULL or
> otherwise erroneous.
>
> Just looking for some educated thoughts/opinions. Thanks.


What exactly are you doing in the copy constructor of 'myClass'?
IOW, post more code.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


  Réponse avec citation
 
Page generated in 0,04550 seconds with 9 queries