Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim ADCOCK) Newsgroups: comp.lang.c++ Subject: Re: asking an object for its type Message-ID: <70951@microsoft.UUCP> Date: 28 Feb 91 17:37:21 GMT References: <23984@netcom.COM> <1190@sheol.UUCP> <1991Feb19.000449.22255@gpu.utcs.utoronto.ca> <607@taumet.com> <65451@brunix.UUCP> <11284@pasteur.Berkeley.EDU> <70870@microsoft.UUCP> <8608@exodus.Eng.Sun.COM> Reply-To: jimad@microsoft.UUCP (Jim ADCOCK) Organization: Microsoft Corp., Redmond WA Lines: 23 In article <8608@exodus.Eng.Sun.COM> chased@rbbb.Eng.Sun.COM (David Chase) writes: |In article <70870@microsoft.UUCP> jimad@microsoft.UUCP (Jim ADCOCK) writes: |>A "trivial" solution to the run-time type problem ought to be closer |>to O(1) than O(N), where N is the number of classes that need to have |>some notion of run-time type. ... | |Do note that (using algorithms known to me) run-time type-checks and |subtype queries can be implemented much more efficiently in the |single-inheritance case. This doesn't directly help C++, unless you |choose to limit the problem that you are trying to solve. Sorry, I guess I made myself pretty unclear. I meant to imply O(N) programmer effort -- not O(N) time. Given N classes, the programmer is going to have to specify type information in O(N) places. Clearly this is a violation of encapsulation. If C++ "supported" run-time typing, the programmer ought to be able to specify the needed run-time information in O(1) places -- in a single superclass, for example. This could be done if C++ provided a way to specify some "templated" information in a superclass, with that template expanded "automatically" without programmer intervention in all subclasses. But, the present template definitions don't seem to allow for such a possibility. Correct me if I've missed something.