Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!helios.ee.lbl.gov!pasteur!homer.Berkeley.EDU!mcgrath From: mcgrath@homer.Berkeley.EDU (Roland McGrath) Newsgroups: comp.std.c++ Subject: Re: Separate Decl of Private Member Fcn Message-ID: Date: 8 Aug 90 02:08:30 GMT References: <259400001@inmet> <32527@sparkyfs.istc.sri.com> Sender: news@pasteur.Berkeley.EDU Organization: Hackers Anonymous International, Ltd., Inc. (Applications welcome) Lines: 32 X-Local-Date: 7 Aug 90 19:08:30 PDT In-reply-to: mckenney@sparkyfs.istc.sri.com's message of 7 Aug 90 17:50:19 GMT In article <32527@sparkyfs.istc.sri.com> mckenney@sparkyfs.istc.sri.com (Paul Mckenney) writes: In article <259400001@inmet> stt@inmet.inmet.com writes: > >It seems to be a major maintenance/recompilation headache that any >private utility function which is to be used to implement >public member functions must be declared in the class declaration, >either as a private member function, or as a friend. > [ . . . ] >This issue is discussed in E&S 9.3, bottom of page 174, but >I find the argument unconvincing: > "Why can't functions be added to a class after the end > of the class declaration? If this were allowed, a user > could gain access to a class simply by declaring an additional > function." >[ . . . ] Where is the danger? The danger is that a programmer could hijack a call that was intended to invoke a base-class member function: [...] This hijacking could be hidden deep inside a large, complex system and be very difficult to find, especially if classes A and B had been thoroughly debugged and were hence presumed innocent. This a good argument for programmers not doing this sort of thing, since it may make their lives more difficult down the road. Why, however, should they be prohibited from doing it? Sure sounds like a victimless crime to me.... -- Roland McGrath Free Software Foundation, Inc. roland@ai.mit.edu, uunet!ai.mit.edu!roland