virtual table pointer confused


D

dost

please see the following code.
class A
{
public:
virtual void F1(){printf("\nclass A :: F1() ");}
};
class B : public A
{
public:
virtual void F2(){printf("\nclass B :: F1() ");}
};

int _tmain(int argc, _TCHAR* argv[])
{
A *pA = new A(); //
B *pB = new B(); // Question A
}

Hi
In the above code i was looking for virtual table pointer values on
both statement.
1 A *pA = new A(); here i see when object is created a new vptr is
created and it has the address in static array for function A ::
F1().
2. B *pB = new B(); here i see the vptr address is different which is
obvious and the address and entry of A :: F1(). But i cant see the
entry of function B :: F2().
thank you
 
Ad

Advertisements

D

dost

please see the following code.
class A
{
        public:
        virtual void F1(){printf("\nclass A :: F1()   ");}};

class B : public A
{
        public:
        virtual void F2(){printf("\nclass B :: F1()   ");}

};

int _tmain(int argc, _TCHAR* argv[])
{
   A *pA = new A(); //
   B *pB = new B(); // Question A

}

Hi
In the above code i was looking for virtual table pointer values on
both statement.
1    A *pA = new A();  here i see when object is created a new vptr is
created and it has the address in static array for function  A ::
F1().
2.  B *pB = new B(); here i see the vptr address is different which is
obvious  and the address and entry of A :: F1(). But i cant see the
entry of function  B :: F2().
thank you

where is the entry of B :: F2().
 
S

Stuart Redmann

please see the following code.
class A
{
public:
virtual void F1(){printf("\nclass A :: F1() ");}};
class B : public A
{
public:
virtual void F2(){printf("\nclass B :: F1() ");}

int _tmain(int argc, _TCHAR* argv[])
{
A *pA = new A(); //
B *pB = new B(); // Question A

Hi
In the above code i was looking for virtual table pointer values on
both statement.
1 A *pA = new A(); here i see when object is created a new vptr is
created and it has the address in static array for function A ::
F1().
2. B *pB = new B(); here i see the vptr address is different which is
obvious and the address and entry of A :: F1(). But i cant see the
entry of function B :: F2().
thank you

where is the entry of B :: F2().

You should be a bit more specific about your problem. I guess that you
mean that you cannot see the vtable-entries for B::F2 in the debugger
window of MS Visual Studio 20XX. This is by design.

Regards,
Stuart
 
D

dost

please see the following code.
class A
{
        public:
        virtual void F1(){printf("\nclass A :: F1()   ");}};
class B : public A
{
        public:
        virtual void F2(){printf("\nclass B :: F1()   ");}
};
int _tmain(int argc, _TCHAR* argv[])
{
   A *pA = new A(); //
   B *pB = new B(); // Question A
}
Hi
In the above code i was looking for virtual table pointer values on
both statement.
1    A *pA = new A();  here i see when object is created a new vptr is
created and it has the address in static array for function  A ::
F1().
2.  B *pB = new B(); here i see the vptr address is different which is
obvious  and the address and entry of A :: F1(). But i cant see the
entry of function  B :: F2().
thank you
where is the entry of B :: F2().

You should be a bit more specific about your problem. I guess that you
mean that you cannot see the vtable-entries for B::F2 in the debugger
window of MS Visual Studio 20XX. This is by design.

Regards,
Stuart
@stuart i am sorry for that. well you are right its about looking in
debugger window.
So can to tell me another way of checking the entries in vptr.
thakyou
 
S

Stuart Redmann

On 10 Mai, dost wrote:
please see the following code.
class A
{
        public:
        virtual void F1(){printf("\nclass A :: F1()   ");}};
class B : public A
{
        public:
        virtual void F2(){printf("\nclass B :: F1()   ");}
};
int _tmain(int argc, _TCHAR* argv[])
{
   A *pA = new A(); //
   B *pB = new B(); // Question A
}
Hi
In the above code i was looking for virtual table pointer values on
both statement.
1    A *pA = new A();  here i see when object is created a new vptr is
created and it has the address in static array for function  A ::
F1().
2.  B *pB = new B(); here i see the vptr address is different which is
obvious  and the address and entry of A :: F1(). But i cant see the
entry of function  B :: F2().
thank you
where is the entry of B :: F2().
You should be a bit more specific about your problem. I guess that you
mean that you cannot see the vtable-entries for B::F2 in the debugger
window of MS Visual Studio 20XX. This is by design.
Regards,
Stuart

@stuart i am sorry for that. well you are right its about looking in
debugger window.
So can to tell me another way of checking the entries in vptr.
thakyou>

I'm sorry, AFAIK there is no way to view all vtable entries.

Regards,
Stuart
 
K

Krice

@stuart i am sorry for that. well you are right its about looking in
debugger window.
So can to tell me another way of checking the entries in vptr.

So, why do you need to know anything about how the underlying
vtable is working? Just let it do the magic.
 
Ad

Advertisements


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

Top