Virual Functions mechanism

R

Ram

Hi,



Please clarify my below mentioned doubts,



1. Virtual functions addresses are stored in Virtual table, but how about
the Virtual destructor?



2. Is the Virtual destructor also treated as just like any other function
except the calling mechanism?



3. Could you please refer me a book/Website where I can find the detailed
information about the Virtual function and internal details.? What happens
at the compile time and Run time in detail?





Thanks & Regards,

Ram
 
A

Alf P. Steinbach

* Ram:
Hi,



Please clarify my below mentioned doubts,



1. Virtual functions addresses are stored in Virtual table,

Are they?

but how about the Virtual destructor?

Usually treated in exactly the same way as other virtual functions.

2. Is the Virtual destructor also treated as just like any other function
except the calling mechanism?
No.


3. Could you please refer me a book/Website where I can find the detailed
information about the Virtual function and internal details.? What happens
at the compile time and Run time in detail?

See <url: http://home.no.net/dubjai/win32cpptut/special/pointers/ch_01.pdf>.
 
J

Jens Theisen

All of this is implementation dependent, though as far as I know they
don't vary too much as far as you're questions are concerned.
1. Virtual functions addresses are stored in Virtual table, but how about
the Virtual destructor?

At least on my platform, there is technically more than one dtor, two
of them virtual, one of them not. Don't ask me why.
2. Is the Virtual destructor also treated as just like any other function
except the calling mechanism?

As little as ctors are normal non-virtual functions.
3. Could you please refer me a book/Website where I can find the detailed
information about the Virtual function and internal details.? What happens
at the compile time and Run time in detail?

One unfortunately very outdated and also somewhat superficial book
which is often cited when such questions come up is `Inside the C++
object model'.

I would nevertheless suggest it as a starting point, if you have
access to it.

Since it's platform dependent, you might find it documented for your
platform. For example, gcc adheres to the Itanium C++ ABI (google for
itanium and abi), even on systems other than Itanium, and Linux
systems are required that their compiler do so by LSB.

This document is a bit difficult to understand if you're not familiar
with the basics though (admittedly I don't understand too much).

It's still useful to realise _how_ complex matters are.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top