Solved

How can I keep the private methods and properties of the "dllexport class" in a MFC DLL secret.

Posted on 2003-10-26
2
350 Views
Last Modified: 2013-11-20
I create a MFC DLL Project using Visual C++ 6.0 and one class is declared as "class __declspec(dllexport) CHLSmSock" to be used by other applications. But  two question are raised.
  1. I have to include the ".h" file in another application when using this dll. I don't want the private methods of this class be seen by other applications, but the ".h" file of the class show the declaration of those private methods. How can I keep them secret.
   2. The types of some private properties are inner classes of the MFC DLL. So when I use the dll in another application by including the ".h" and complie the project, the shown error message tell me that some classes are undeclared. But the classes are declared in the MFC DLL.

  How can I solve  these questions?
0
Comment
Question by:Iaskyou
2 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
Create a new class, and write all those functions in that class. In your DLL call appropriate functions of that class when needed.
Rosh :)
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 130 total points
Comment Utility
To avoid including h-files fot inner classes in the client project use forward declarations and pointers:

// HLSmSock.h

class A;       // inner class forward declaration

class CHLSmSock            // exported class
{
    ...
    A* pA;     // pointer, not instance
};


// HLSmSock.cpp

#include "HLSmSock.h"
#include "A.h"                   // include inner class only to cpp-file

// create A instance in CHLSmSock constructor:
// pA = new A();
// and release it in CHLSmSock destructor




0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now