• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

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

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
Iaskyou
Asked:
Iaskyou
1 Solution
 
Roshan DavisCommented:
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
 
AlexFMCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now