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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:49:27+00:00 2026-05-24T01:49:27+00:00

I have a class which has two overloaded functions. How do I export it

  • 0

I have a class which has two overloaded functions. How do I export it from a dll and also how to use it by other C++ classes? My class looks like this:

#define DECLDIREXP __declspec(dllexport) 

#define DECLDIRIMP __declspec(dllimport)


class DECLDIREXP xyz 

{

public: 
          void printing();
          void printing(int a);
};  

using namespace std; 

void xyz::printing()
{
        cout<<"hello i donot take any argument";
}


void xyz::printing(int a)
{
        cout<<"hello i take "<< a <<"as argument";
}
  • 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-24T01:49:28+00:00Added an answer on May 24, 2026 at 1:49 am

    A common approach is to have a single macro (let’s call it EXPORT) which either expands to dllimport or dllexport depending on whether some sort of “building the DLL right now” define is set, like this:

    #ifdef MAKEDLL
    #  define EXPORT __declspec(dllexport)
    #else
    #  define EXPORT __declspec(dllimport)
    #endif
    
    class EXPORT xyz {
      // ...
    };
    

    The idea is that when building your DLL, you add MAKEDLL to the preprocessor definitions. That way, all the code will be exported. Clients who link against your DLL (and hence include this header file) don’t need to do anything at all. By not defining MAKEDLL, they will automatically import all the code.

    The advantage of this approach is that the burden of getting the macros right is moved from the many (the clients) to just the author of the DLL.

    The disadvantage of this is that when using the code above as it is, it’s no longer possible to just compile the code directly into some client module since it’s not possible to define the EXPORT macro to nothing. To achieve that, you’d need to have another check which, if true, defines EXPORT to nothing.

    On a slightly different topic: in many cases, it’s not possible (or desired!) to export a complete class like that. Instead, you may want to just export the symbols you need. For instance, in your case, you may want to just export the two public methods. That way, all the private/protected members won’t be exported:

    class xyz
    {
    public: 
        EXPORT void printing();
        EXPORT void printing(int a);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class which has two HashSet<String> collections as private members. Other classes
I have a base class which has two child classes derived from it. class
I have a class that has two functions, both of which take a different
I have a class A, which has two functions (Download and query). When the
I have a IEnumerable. I have a custom Interval class which just has two
I have a base class, B, which has two constructors, one with no paremeters
I have a class which has many small functions. By small functions, I mean
I have a class which has a function to retrieve children elements from a
I have simple ontology called campus.owl.There is a class calledLecturer and which has two
I have two or more variables of class object in c# which has integer

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.