| |

VerySource

 Forgot password?
 Register
Search
View: 679|Reply: 1

Problems with virtual function tables

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-2 21:50:02
| Show all posts |Read mode
In the debug window of VC, why can I only see the virtual function inherited from the parent class in the virtual function table of the subclass? Why can't I see its own virtual function? Thank you!
Reply

Use magic Report

0

Threads

37

Posts

28.00

Credits

Newbie

Rank: 1

Credits
28.00

 China

Post time: 2020-1-2 22:45:02
| Show all posts
This is completely a display problem of the compiler. You can take out each item in the virtual table by pointer operation.

Derived * p = new Derived ()
int * addr = reinterpret_cast <int *> (p);
int * vptr = reinterpret_cast <int *> (* addr);

// Take the items in the virtual table:
int * func1 = reinterpret_cast <int *> (vptr [0]);
int * func2 = reinterpret_cast <int *> (vptr [1]);

Then I checked the values ​​of func1 and func2 in DEBUG. I did this when I encountered this problem. It was a bit troublesome. Maybe there is a better way.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list