Path: utzoo!attcan!uunet!ateng!chip From: chip@ateng.uucp (Chip Salzenberg) Newsgroups: comp.lang.c++ Subject: Re: Friend specifier considered harmful Message-ID: <1988Sep15.151514.20657@ateng.uucp> Date: 15 Sep 88 19:15:07 GMT References: <61@cybaswan.UUCP> <1988Sep2.174327.6439@ateng.uucp> <78@cybaswan.UUCP> Reply-To: chip@ateng.UUCP (Chip Salzenberg) Organization: A T Engineering, Tampa, FL Lines: 28 According to eeartym@cybaswan.UUCP (Dr R. Artym): >chip@ateng.uucp (Chip Salzenberg) writes: >> The HashTable class contains an array of pointers to HashNode. Each >> HashNode contains a pointer to the next HashNode. I made HashTable a friend >> of HashNode. This allowed easy access to the HashNode "next" pointer but >> _only_ for HashTable member functions. > >I see no reason why the HashTable can't request the preceding HashNode to >place the new HashNode pointer in its next field. Of course, I could have done it that way. But I chose the "friendly" approach so that other classes besides HashTable couldn't even _see_ the next pointer, much less modify it. >Why this structure anyway? --- it's the C approach, not C++! You ought to >have an array of lists in HashTable, with the lists carrying HashNode objects >without a next field. But you're wrong! Linked lists are a useful data structure no matter what the language. ...Although I find it interesting that the interface I used would permit changing to arrays instead of linked lists without modifying the HashTable interface at all. This is a good sign. -- Chip Salzenberg or A T Engineering My employer may or may not agree with me. The urgent leaves no time for the important.