Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!ulysses!hector!jss From: jss@hector.UUCP (Jerry Schwarz) Newsgroups: comp.lang.c++ Subject: Re: address of virtual function (revisited) Message-ID: <11497@ulysses.homer.nj.att.com> Date: 8 May 89 14:36:01 GMT References: <904@garya.Solbourne.COM> <6590114@hplsla.HP.COM> Sender: netnews@ulysses.homer.nj.att.com Reply-To: jss@hector.UUCP (Jerry Schwarz) Organization: AT&T Bell Laboratories Lines: 42 In article <6590114@hplsla.HP.COM> jima@hplsla.HP.COM (Jim Adcock) writes: > >Again, for OOP to be affordable, these simple, everyday "get" and >"put" type functionalities must be handled at minimal cost. >Otherwise programmers will violate strict encapsulation, and come >up with "hack" solutions. I get a frustrated by assertions of this kind. By any standard C++ is "affordable", especially when compared to languages like Smalltalk or Objective C. Note that the item I am replying to was sumbmitted only to comp.lang.c++ so I have to read this as a suggestion that C++ isn't "affortdable". (I suppose I could also read this as an argument for my contention that C++ supports non object oriented styles and therefore derives its affordability by avoiding OOP when neccessary, but the tenor of the item I'm replying to doesn't suggest that reading to me. I apologize if I'm misreading Jim Adcocks note.) In fact, C++ puts you at a low enough level so that (with out violating the type discipline) it is possible to program the operation under discussion (finding the "actual" size of an object) as a simple lookup. class B public const size_t size ; B(int i) : Size(i) ; } ; class D : B { D(...) : B(sizeof(D)) { ... } } ; B* p ; ... p->size ... ; Yes, there is a certain amount of pain involved in programming this explicitly. But recall that the original complaint was that C++ doesn't provided an "affordable" enough way to do this operation. Jerry Schwarz AT&T Bell Labs, Murray Hill