Re: abstract classes and dynamic binding
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
---910079544-514791883-1217337228=:20037
Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1; FORMAT=flowed
Content-Transfer-Encoding: 8BIT
Content-ID: <Pine.LNX.4.64.0807291414151.20037@urchin.earth.li>
On Mon, 28 Jul 2008, Peter Duniho wrote:
On Mon, 28 Jul 2008 19:35:55 -0700, Stefan Ram <ram@zedat.fu-berlin.de>
wrote:
conrad <conrad@lawyer.com> writes:
How does the JVM know that obj1's getArea method is the one
implemented by the Circle class?
The type of objects is stored with them, and can be accessed at
run-time. So it can be used by the JVM at run-time.
That's all true, but isn't actually how "the JVM knows that obj1's
getArea method is the one implemented by the Circle class".
Actually, this is the most elementar meaning of ?object-oriented
programming?: Dealing with entities with run-time type information (by
polymorphism).
Unless specifically compiled with run-time type information (RTTI), C++
has no RTTI.
A vtable is run-time type information. It isn't RTTI, but it is undeniably
information about a type that is available at runtime.
The point i'm making is that i don't think Stefan was using the phrase
"run-time type information" in the specific C++ sense, but more generally,
to mean information which the VM can use to resolve virtual method calls
at runtime. Since this isn't a C++ newsgroup, i'd say that was was
acceptable use, if perhaps prone to lead to confusion amongst C++
programmers.
Anyway, Peter, for completeness, now explain how virtual dispatch works
when the variable is of interface, not class, type ... :)
tom
--
The glass is twice as big as it needs to be.
---910079544-514791883-1217337228=:20037--