JustBoo wrote:
On 4 Jan 2006 09:24:59 -0500, "Meador Inge" <me*****@gmail. com> wrote:Earl Purple wrote: yp*********@ind iatimes.com wrote:
The v-table is beyond C++. You cannot access it directly, or get a
pointer to a v-table.
That is not 100% true. One could figure out how a particular compiler
implements the v-table and access it using various casts and pointer
arithmetic. Not that I would suggest doing such a thing, but it is
possible nonetheless.
That is how Microsoft COM works. It "walks" the vtable. IIRC COM is an
external process so it has to get hold of the vtable just like any
programmer would have to. It helps a great deal to know how this
mechanism works.
To the OP, ignore people who tell you to "MYOB" or it's out of your
control so don't bother. People like that, regardless of their title
and/or education, are NOT engineers, software or otherwise.
In my response, I wrote:
"The short answer: MYOB. It's implementation defined and not explicitly
accessible to your C++ program. See this FAQ (and the preceding one)
for some details:
http://www.parashift.c om/c++-faq-lite/virtual-functions.html# faq-20.4"
Since your comments are at least directed at me, please allow me to
respond.
The "MYOB" in my response was half joking. Of course, in some
relatively rare scenarios it might be necessary to figure out how a
compiler implements virtual functions and make use of that information
(n.b., compilers aren't required to use vtables at all and can
implement virtual functions with some other mechanism). However, as I
said, the language does not make that information *explicitly*
available to the user, and so the user *must* do some
platform-dependent pointer manipulation to figure out where the vtable
is and how to use it (assuming it exists at all!).
Therefore, since this newsgroup is exclusively concerned with
*standard* C++ language and libraries
(
http://www.parashift.com/c++-faq-lit....html#faq-5.9), such
manipulations are, according to the FAQ, off-topic here and should be
taken to a more specific newsgroup that can treat them more adequately.
As far as implementing COM, Microsoft is free to make use of
non-standard information because it also controls the compiler. Another
company creating a COM-esque technology for some third-party
compiler(s) might pull the same sort of non-standard tricks, only to
find out on the next release of their compiler(s) that their tricks for
manipulating the vtable no longer work. That is because they used a
non-standard implementation detail from one version of their compiler
that the Standard allows the compiler vendor to change at will without
becoming non-conformant.
Finally, with regard to the aspersions and calumnies cast about in your
last sentence, I would humbly recommend that you dismount from your
elevated equine.
Cheers! --M