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 7022391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:34:34+00:00 2026-05-27T23:34:34+00:00

Lets say there is a class named Person which contains a virtual function named

  • 0

Lets say there is a class named Person which contains a virtual function named age(). As per language semantics, vtable is per class and not per object. It is VPTR which is per object and points to vtable.

Questions:

If I build this program (lets say main() exist):

  1. Will the vtable be created i.e can vtable comes in existence w/o even creating a single object?

  2. The address which is put by compiler in vtable for age() is a kind of some static address in memory?

  3. Or is it that compiler internally creates some object for obtaining the address to age() (since age() will be working on some data members which can come in existence only when an object is constructed) or there is some other magic behind this?

As per my understanding, the answers are as follows:

  1. Yes
  2. Yes
  3. Not sure

I tried running “nm” on above program just to see if I can figure out the vtable, but no luck. Is there a way to do so?

Please suggest.

  • 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-05-27T23:34:35+00:00Added an answer on May 27, 2026 at 11:34 pm

    “As per language semantics,” there’s no such thing as a vtable. The C++ specification does not specify exactly how virtual dispatch is implemented. A compiler could use vtables. Or it could use something else; that’s up to the compiler.

    A specific compiler can use vtables of course. But it can do whatever it wants with them; that’s an implementation detail. In short, there’s no way for you to know without investigating the specific compiler you’re using.

    And really, does it matter that much?

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

Sidebar

Related Questions

Lets say there is a Person class that holds some attributes and some other
So lets say I have these classes: public class Person { public string Name
Let's say I have 2 instances of Person class. One named john and one
Let's say I have a class Person with properties name and age , and
Lets say I have an object class Person { public string Name { get;
Lets say that one has a class like Person that has associated with it
Lets say I have a domain class named Tag in my Grails application. class
Let's say you have a class with a Uri property. Is there any way
Let's say I have a Base class and several Derived classes. Is there any
In VB.NET there is a keyword 'shadows'. Let's say I have a base class

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.