What is Data Type of Vptr pointer

V

Veeru

Hi ,
What is the data type of Vptr pointer used in the virtual funtion
mechanism?
i suppose its void. Please correct me if i am wrong...

Regards,
Veeru
 
V

Victor Bazarov

Veeru said:
What is the data type of Vptr pointer used in the virtual funtion
mechanism?
i suppose its void. Please correct me if i am wrong...

Not sure what 'Vptr' you mean. Do you mean 'vtbl'? If so, it is not
defined in C++. It's an ipmlementation detail, and as such has no
representation/definition in C++ proper.

V
 
M

Murali Krishna

Veeru said:
i searched in the FAQ but didnt find the answer to my question. i
wanted to know the data type of the Vptr pointer the points to the
Vbtl(virtual table) which contains the function pointers to virtual
functions.

Please help.

Regards,
Veeru

I think you have faced this in an interview. I have not seen about
VPtr's data-type till now. but as written in FAQs, you can understand
that it is a generic pointer (say void*) to a generic member function
because it stores the starting address of the V-Table.

I guess it is void*.

-- Murali Krishna.
 
V

Veeru

Murali said:
I think you have faced this in an interview. I have not seen about
VPtr's data-type till now. but as written in FAQs, you can understand
that it is a generic pointer (say void*) to a generic member function
because it stores the starting address of the V-Table.

I guess it is void*.

-- Murali Krishna.


Thanks Murali for such a quick response.
There are two possibilities as far as i can see now:
1. Either Vptr could be a void *
OR
2. V-Table must be some kind of an internal hidden sturture or class.
And the Vptr points to the V-Table. So Vptr could have a data type of
V-Table.

Well, this is just what i can guess.
But still need a confimation.

Regards,
Veeru
 
K

Kai-Uwe Bux

Veeru said:
Thanks Murali for such a quick response.
There are two possibilities as far as i can see now:
1. Either Vptr could be a void *
OR
2. V-Table must be some kind of an internal hidden sturture or class.
And the Vptr points to the V-Table. So Vptr could have a data type of
V-Table.

Well, this is just what i can guess.
But still need a confimation.

There is no way to confirm this: the c++ standard does not even require that
v-tables exist. In particular, it does not prescribe the types and data
structures used to implement the dispatch mechanism for virtual functions.
Thus, your question does not have a general answer. If you are interested
in how a given implementation does it, then you should ask your question in
a forum dedicated to that particular implementation.


Best

Kai-Uwe Bux
 
T

tragomaskhalos

Veeru said:
Hi ,
What is the data type of Vptr pointer used in the virtual funtion
mechanism?
i suppose its void. Please correct me if i am wrong...

Your question actually makes no sense - virtual function dispatch is a
language internal feature, and as such has nothing to do with the type
system.
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top