Is it possible to get access to the virtual pointer i.e pointer to the virtual table in a polymorphic class.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In general, no, the standard is agnostic about how the virtual dispatch is implemented, so as far as it is concerned
virtualclasses may not even have a vptr and a vtable.The vptr is an implementation detail, you should look at your compiler documentation to check if there’s a documented way to access it (but I’ve never heard of compiler builtins to do this), otherwise you have to look at the assembly output to determine its position.
Out of curiosity, why do you need to access the vptr?