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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:28:20+00:00 2026-05-29T09:28:20+00:00

I have a C++ header declaring a class composed of pure virtual methods only.

  • 0

I have a C++ header declaring a class composed of pure virtual methods only. I have two DLLs using that header, (with one implementing that interface) but not linked at compile time. One DLL is loading the other one dynamically, passing a pointer of the implemented interface to the other. Are these DLL’s sharing the same virtual table structure?

  • 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-29T09:28:21+00:00Added an answer on May 29, 2026 at 9:28 am

    You’re safe.

    The order in which the methods appear in the vftable is determined by the base class structure, and that’s all you should care about. But this is compiler specific, so use the same compiler for generating the dll’s. Don’t rely on them being backward-compatible (or at least check the documentation).

    Assume you have the following header:

    //header.h
    
    class A
    {
    public:
        virtual void foo() = 0;
        virtual void goo() = 0;
    };
    

    And you have B.dll with the following class:

    class B : public A
    {
    public:
        virtual void foo() {}
        virtual void goo() {}
    }
    

    Now, in X.dll, you receive a pointer to an A that is a B object created in B.dll.

    The call

    void test( A* a )
    { 
       a->foo();
    }
    

    will invoke B::foo().

    One neat experiment you can try is to compile B.dll with header.h and when you compile X.dll, invert the order of the methods in header.h:

    //header.h
    
    class A
    {
    public:
        virtual void goo() = 0;
        virtual void foo() = 0;
    };
    

    In this case, although you should never do this, the same call to test() in X.dll will probably call the method B::goo(). That is because X.dll assumes the vftable present in the header. It’s undefined behavior though; I just wrote this example to make a point.

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

Sidebar

Related Questions

I have a header declaring functions that take pointers to C++ objects as parameters.
I have a header file, lets say Common.h, that is included in all of
I have a program using 3 header files and 3 .cpp files in addition
In a header file, I have forward declared two members of a namespace: namespace
I have the following code and I wanted to create a class that encapsulates
I want to add one HTML file into another. For example: I have header.html
Possible Duplicate: Declaring a function that return a 2D array in a header file?
I have a relatively large class that I'm working with and it's all worked
I am declaring an array of NSString* in a header file of a class.
I have Visual studio 2005 . One of my header file has a enum

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.