Afficher un message
Vieux 16/10/2007, 08h47   #3
djm
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: making a struct array NULL?

On Oct 16, 12:40 pm, "Jim Langston" <tazmas...@rocketmail.com> wrote:
> "djm" <djmlog...@gmail.com> wrote in message
>
> news:1192519330.761691.111890@k35g2000prh.googlegr oups.com...
>
>
>
> > hi,
> > lets say ive this struct array in my header file

>
> > public:
> > IndepHTable();
> > private:
> > struct
> > {
> > string word;
> > List defList;
> > } dictionary[TABLE_SIZE];

>
> > how can i make the elements in the array null from the constructor?

>
> > will this work?

>
> > IndepHTable::IndepHTable()
> > {

>
> > word.clear();
> > defList=NULL;

>
> > }
> > or something like
> > this?

>
> > IndepHTable::IndepHTable(dictionary l)
> > {
> > for(int i=0;i<29;i++)
> > {
> > l[i].word.clear();
> > l[i].defList=NULL;
> > }
> > }

>
> > i tried but none of the work. can someone me out?
> > thanks

>
> if your string is a std::string then it will already be "cleared". I don't
> know what your List is, what does it's default constructor do?
>
> You are saying defList = NULL, but that presumes that List is a pointer, is
> it? Probably not, it's probably a class.
>
> Most likely, you won't have to do anything, although, again, it depends on
> what List is.


sorry for the lack of info.
the pruporse is to make a linked list with rehasing techniques. the
list is a class and that has nodes, the values of the objects in the
nodes are made in to initial values by thier constructors, as you said
i realise that i dont need to make the defList to NULL cuz its already
made null. but what about the string? what if i want to make it null
so that it wont have any garbage values when i declare them?

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