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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:48:52+00:00 2026-05-27T03:48:52+00:00

Given the classes Foo and Bar where Bar is derived from Foo , how

  • 0

Given the classes Foo and Bar where Bar is derived from Foo, how could I export Bar without having to export Foo ?

Foo.h

class Foo
{
    public:
        Foo();
        virtual bool Read(...);
        virtual bool Write(...);
        ~Foo();
};

Bar.h

#ifdef BUILD_DLL
#    include "Foo.h"
#    define EXTERNAL __declspec(dllexport)
#else
#    define EXTERNAL __declspec(dllimport)
#endif 

class EXTERNAL Bar: public Foo
{
    public:
        Bar();
        bool Read(...);
        bool Write(...);
        ~Bar();
};

Edit

This is the warning that Visual C++ 2010 gives me:

warning C4275: non dll-interface class ‘Foo’ used as base for dll-interface class ‘Bar’

Edit #2

Here’s what I did to sort-of solve the issue. I made Foo and Bar separate DLL’s. The client application links to Bar.dll and Bar.dll links to Foo.dll. This works well for what I was trying to achieve…

  • 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-27T03:48:52+00:00Added an answer on May 27, 2026 at 3:48 am

    Doesn’t that work? It should. Just because you’re not explicitly exporting the class doesn’t mean the logic isn’t in the binary. The symbols just aren’t visible to anything importing that class.

    Your solution should do it. Are you getting linking errors or what?

    EDIT: I just saw you only include the header for Foo in one case. You don’t need to do that:

    #ifdef BUILD_DLL
    #    define EXTERNAL __declspec(dllexport)
    #else
    #    define EXTERNAL __declspec(dllimport)
    #endif 
    
    #include "Foo.h"
    
    class EXTERNAL Bar: public Foo
    {
        public:
            Bar();
            bool Read(...);
            bool Write(...);
            ~Bar();
    };
    

    This way you can’t use Foo in a different module since it’s not exported, but you can use and declare Bar.

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

Sidebar

Related Questions

Given the following classes: class foo { private: int c; public: foo( int a
Given these classes: using System.Collections.Generic; namespace FluentMappingsQuestion { public class Entity { public virtual
Given class Foo template <typename T> class Foo { public: ...other methods.. void bar()
Given the following in PHP: <?php class foo { public $bar; function __construct() {
Given the following example classes in my.package ... public class Foo { public void
Given <div class=foo> <span class=bar></span> </div> I've always defined the CSS classes as: .foo
Given two model classes, Foo and Bar , I want Foo to have 3
This is easier to explain with an example. Given these two classes: public class
Updated question given Andrew Hare's correct answer: Given the following C# classes: public class
In C# you can easily read all classes from a given assembly. I'm looking

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.