What is Data Type of Vptr pointer

Discussion in 'C++' started by Veeru, Sep 13, 2006.

  1. Veeru

    Veeru Guest

    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
    Veeru, Sep 13, 2006
    #1
    1. Advertising

  2. Veeru wrote:
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Sep 13, 2006
    #2
    1. Advertising

  3. Murali Krishna, Sep 14, 2006
    #3
  4. Veeru

    Veeru Guest

    Murali Krishna wrote:

    > Veeru wrote:
    > > 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

    >
    > your question was answered in Marshall Cline's FAQs
    >
    > see this..
    > http://www.parashift.com/c -faq-lite/virtual-functions.html#faq-20.4
    >
    > -- Murali Krishna


    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
    Veeru, Sep 15, 2006
    #4
  5. Veeru wrote:
    > Murali Krishna wrote:
    >
    > > Veeru wrote:
    > > > 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

    > >
    > > your question was answered in Marshall Cline's FAQs
    > >
    > > see this..
    > > http://www.parashift.com/c -faq-lite/virtual-functions.html#faq-20.4
    > >
    > > -- Murali Krishna

    >
    > 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.
    Murali Krishna, Sep 15, 2006
    #5
  6. Veeru

    Veeru Guest

    Murali Krishna wrote:

    > Veeru wrote:
    > > Murali Krishna wrote:
    > >
    > > > Veeru wrote:
    > > > > 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
    > > >
    > > > your question was answered in Marshall Cline's FAQs
    > > >
    > > > see this..
    > > > http://www.parashift.com/c -faq-lite/virtual-functions.html#faq-20.4
    > > >
    > > > -- Murali Krishna

    > >
    > > 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.



    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
    Veeru, Sep 15, 2006
    #6
  7. Veeru

    Kai-Uwe Bux Guest

    Veeru wrote:

    >
    > Murali Krishna wrote:
    >
    >> Veeru wrote:
    >> > Murali Krishna wrote:
    >> >
    >> > > Veeru wrote:
    >> > > > 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
    >> > >
    >> > > your question was answered in Marshall Cline's FAQs
    >> > >
    >> > > see this..
    >> > > http://www.parashift.com/c -faq-lite/virtual-functions.html#faq-20.4
    >> > >
    >> > > -- Murali Krishna
    >> >
    >> > 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.

    >
    >
    > 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
    Kai-Uwe Bux, Sep 15, 2006
    #7
  8. Veeru wrote:
    > 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.
    tragomaskhalos, Sep 15, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pai
    Replies:
    4
    Views:
    920
  2. Subhransu Sahoo

    A basic doubt on VPTR and VTABLES

    Subhransu Sahoo, Nov 7, 2006, in forum: C++
    Replies:
    4
    Views:
    336
  3. Rahul

    vptr

    Rahul, Nov 4, 2007, in forum: C++
    Replies:
    3
    Views:
    638
    =?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
    Nov 4, 2007
  4. Thomas Lenz

    vtbl and vptr

    Thomas Lenz, Dec 16, 2008, in forum: C++
    Replies:
    18
    Views:
    1,679
    Laurent Deniau
    Dec 17, 2008
  5. VPTR and VTABLE

    , Dec 1, 2009, in forum: C++
    Replies:
    9
    Views:
    4,098
    James Kanze
    Dec 2, 2009
Loading...

Share This Page