Home > Archive > VC Language > November 2005 > Question abt VTable??
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Question abt VTable??
|
|
| Dkds.Naidu 2005-11-23, 7:59 am |
| Hi,
Where VTable stores?
VTable creating in the run time means, before constructor or after
constructor???
Thanks in advance.
Regards,
--
DKDS.Naidu.
| |
| Tom Widmer [VC++ MVP] 2005-11-23, 7:59 am |
| Dkds.Naidu wrote:
> Hi,
>
> Where VTable stores?
In the executable image (e.g. the .exe or .dll itself), just like, for
example, string literals.
> VTable creating in the run time means, before constructor or after
> constructor???
The vtable exists before the program is even run, but a (sub)object of
dynamic type has its vtable pointer set to point to the vtable for the
static class of the constructor before the constructor starts. e.g.
struct A
{
A()
{
f();
}
virtual void f();
};
struct B: A
{
B()
{
f();
}
virtual void f();
};
If you create a B, A::f() will be called by A's constructor and then
B::f() by B's - the vtable pointer is set automatically before A's
constructor and then again before B's.
Obviously this is all specific to implementations that use vtables, such
as MSVC.
Tom
| |
| Ulrich Eckhardt 2005-11-23, 7:59 am |
| Dkds.Naidu wrote:
> Where VTable stores?
The compiler generates the VTable and stores it in the objectfiles it
generates.
> VTable creating in the run time means, before constructor or after
> constructor???
The VTable is not generated at runtime but at compile time, see above.
Uli
| |
| Dkds.Naidu 2005-11-23, 7:59 am |
| How can I get the virtual function addresses through programmatically in any
case??
What is Incremental Link Table????
What is the use of ILT???
--
DKDS.Naidu.
"Tom Widmer [VC++ MVP]" wrote:
> Dkds.Naidu wrote:
>
> In the executable image (e.g. the .exe or .dll itself), just like, for
> example, string literals.
>
>
> The vtable exists before the program is even run, but a (sub)object of
> dynamic type has its vtable pointer set to point to the vtable for the
> static class of the constructor before the constructor starts. e.g.
>
> struct A
> {
> A()
> {
> f();
> }
> virtual void f();
> };
>
> struct B: A
> {
> B()
> {
> f();
> }
> virtual void f();
> };
>
> If you create a B, A::f() will be called by A's constructor and then
> B::f() by B's - the vtable pointer is set automatically before A's
> constructor and then again before B's.
>
> Obviously this is all specific to implementations that use vtables, such
> as MSVC.
>
> Tom
>
| |
| Tom Widmer [VC++ MVP] 2005-11-23, 7:04 pm |
| Dkds.Naidu wrote:
> How can I get the virtual function addresses through programmatically in any
> case??
You can't portably - it depends on the layout of the vtable, which
varies from compiler to compiler and version to version. You can do
something similar with a member function pointer, like &Foo::bar.
> What is Incremental Link Table????
>
> What is the use of ILT???
It is a table of extern function addresses that is updated by the linker
during an incremental link, to avoid having to do a full link where all
function calls are resolved into specific function addresses. Function
calls in incrementally linked builds use the ILT to look up function
addresses rather than calling the function directly.
It doesn't apply to release builds in MSVC, which don't use incremental
linking (by default), but only debug ones.
Tom
| |
| Dkds.Naidu 2005-11-24, 4:01 am |
| In memory, stack or heap or any special memory for this???
what abt ordinary member functions(i mean not polymorphic)???
Where it will be there in memory???
How object links to ordinary member functions??
Thanks in advance.
Regards,
--
DKDS.Naidu.
"Ulrich Eckhardt" wrote:
> Dkds.Naidu wrote:
>
> The compiler generates the VTable and stores it in the objectfiles it
> generates.
>
>
> The VTable is not generated at runtime but at compile time, see above.
>
> Uli
>
>
| |
| Ulrich Eckhardt 2005-11-24, 4:01 am |
| Dkds.Naidu wrote:
> In memory, stack or heap or any special memory for this???
>
> what abt ordinary member functions(i mean not polymorphic)???
>
> Where it will be there in memory???
>
> How object links to ordinary member functions??
I might be able to help you if you took the time to form full sentences.
Alternatively, you newreader quotes the previous posting so you can relate
to it. This is best done by interspersing your questions with the original
message's quotes, trimming parts you don't need.
Please, look at the first of your questions here and ask yourself what the
'this' refers to in that sentence and you will understand what I mean.
Uli
| |
| Tom Widmer [VC++ MVP] 2005-11-24, 7:59 am |
| Dkds.Naidu wrote:
> In memory, stack or heap or any special memory for this???
Part of the executable image - neither heap nor stack, but the same
place all the program code goes.
> what abt ordinary member functions(i mean not polymorphic)???
>
> Where it will be there in memory???
In the .exe of course!
> How object links to ordinary member functions??
It's more the other way around - when a member function is called, the
object is passed as a hidden parameter, the "this" parameter.
Tom
|
|
|
|
|