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

  • Home
  • SEARCH
  • 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 852801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:39:34+00:00 2026-05-15T07:39:34+00:00

I was curious about C++ and virtual inheritance – in particular, the way that

  • 0

I was curious about C++ and virtual inheritance – in particular, the way that vtable conflicts are resolved between bass and child classes. I won’t pretend to understand the specifics on how they work, but what I’ve gleamed so far is that their is a small delay caused by using virtual functions due to that resolution. My question then is if the base class is blank – ie, its virtual functions are defined as:

virtual void doStuff() = 0;

Does this mean that the resolution is not necessary, because there’s only one set of functions to pick from?

Forgive me if this is an stupid question – as I said, I don’t understand how vtables work so I don’t really know any better.

EDIT

So if I have an abstract class with two seperate child classes:

    A
   / \
  /   \
 B     C

There is no performance hit when calling functions from the child classes compared to say, just a single inheritance free class?

  • 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-15T07:39:34+00:00Added an answer on May 15, 2026 at 7:39 am

    There is no hit for calling nonvirtual functions in the child class. If you’re calling an overridden version of your pure virtual function as in your example, then the virtual penalty may still exist. In general it’s difficult for compilers to optimize away the use of the virtual table except under very specific circumstances, where it knows the exact by-value type of the object in question (from context).

    But seriously don’t worry about the overhead. It’s going to be so little that in practice you will almost certainly never encounter a situation where it’s the part of code causing performance bottlenecks. Use virtual functions where they make sense for your design and don’t worry about the (tiny) performance penalty.

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

Sidebar

Related Questions

I am curious how other Resharper users deal wih R#'s complaint about virtual methods
Just curious about what would be the django way of achieving the following :
I am curious about the Custom To-Many Relation Accessors. It makes sense that the
I'm curious about whether there is any way to fake out Array.isArray() with a
I'm curious about people's approaches to using stored procedures in a database that is
I'm curious about OpenID. While I agree that the idea of unified credentials is
Just curious about a particular scenario of NAT. Let's suppose we have 4 computers
I'm just curious about this. It strikes me that the behavior of a StringBuilder
I'm curious about string literals. I've read that in the case of something like
Just curious about the encodings that system is using when handling string storing(if it

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.