Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > virtual table pointer confused

Reply
Thread Tools

virtual table pointer confused

 
 
dost
Guest
Posts: n/a
 
      05-10-2011
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
 
Reply With Quote
 
 
 
 
dost
Guest
Posts: n/a
 
      05-10-2011
On May 10, 11:44*am, dost <(E-Mail Removed)> 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().
 
Reply With Quote
 
 
 
 
Stuart Redmann
Guest
Posts: n/a
 
      05-10-2011
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

 
Reply With Quote
 
dost
Guest
Posts: n/a
 
      05-10-2011
On May 10, 11:56*am, Stuart Redmann <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
Stuart Redmann
Guest
Posts: n/a
 
      05-10-2011
On 10 Mai, 09:07, dost <(E-Mail Removed)> wrote:
> On May 10, 11:56*am, Stuart Redmann <(E-Mail Removed)> wrote:
>
>
>
> > 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
 
Reply With Quote
 
Krice
Guest
Posts: n/a
 
      05-11-2011
On 10 touko, 10:07, dost <(E-Mail Removed)> wrote:
> @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.
 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      05-12-2011
On May 11, 12:31*pm, Krice <(E-Mail Removed)> wrote:
> On 10 touko, 10:07, dost <(E-Mail Removed)> wrote:
>
> > @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.


Probably homework.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
non-virtual call to a virtual function using pointer to member archimed7592 C++ 4 05-30-2007 08:59 PM
Can abstract base class have V-table?, Will the pointer to virtual destructor be entered into the virtual table? sojin C++ 12 04-07-2006 09:02 AM
tweaking the virtual function table pointer =?iso-8859-1?B?RnJhbmstUmVu6SBTY2jkZmVy?= C++ 7 09-23-2005 09:03 PM
Initialization of virtual function table pointer DaKoadMunky C++ 4 04-30-2004 04:46 PM
Virtual functions and virtual base classes - I'm confused Michael Winter C++ 9 09-23-2003 11:17 PM



Advertisments