Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8749941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:46:40+00:00 2026-06-13T12:46:40+00:00

Possible Duplicate: Understanding the vtable entries Using g++ version 4.6.3, 64-bit machine . I

  • 0

Possible Duplicate:
Understanding the vtable entries

Using g++ version 4.6.3, 64-bit machine . I know compiler is free to implement virtual functions any way it wants. I want to know what happened here.

My class:

#include <iostream>
class test
{
    public:
    virtual void func(){std::cout<<"in class test";}
};

int main()
{
    test obj;
    obj.func();
    return 0;
}

Looking at virtual table generated by compiler,

Vtable for test
test::_ZTV4test: 3u entries
0     (int (*)(...))0 (<---- what is this? )
8     (int (*)(...))(& _ZTI4test)
16    (int (*)(...))test::func

At offset 8 it is RTTI

At offset 16 it is entry for virtual function.

My question is why is there entry for NULL at offset 0 or in other words what is the purpose of first entry?

P.S. I thought this could be related to alignment, but then I added more virtual functions but RTTI entry was still at offset 8.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:46:42+00:00Added an answer on June 13, 2026 at 12:46 pm

    I believe the first entry or the entry at 0 the is the offset to top pointer.

    See the following relevant stackoverflow question

    Looking through the remainder -fdump-class-hierarchy from your source code , most classes seem the have the first entry as (int (*)(...))0 , the only classes that don’t have it as the first entry have it as the second and have the first entry as the offset to the parent class given the C++ STL class hierarchy for streams.

    In the relevant question a dead link to some vtable examples is given, I believe a live version of that link is available here

    Another useful resource detailing the structure of vtables is here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Understanding which constructor is chosen and why Why compiler acts like this,
Possible Duplicate: What does *args and **kwargs mean? Understanding kwargs in Python I've found
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: Understanding NSString comparison in Objective-C I've used this simple code for several
Possible Duplicate: Using IoC for Unit Testing I think I do have a Problem
Possible Duplicate: How prepared statements can protect from SQL injection attacks? If I'm using
Possible Duplicate: Understanding region of interest in openCV 2.4 i want to get a
Possible Duplicate: Understanding NSString comparison in Objective-C I'v encountered strange things in objective-c, I'm
Possible Duplicate: Understanding Compile- vs Run-time Dependencies I understand that a dependency with the
Possible Duplicate: C header file loops Original Question: I always had problems understanding why

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.