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
355 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9624848
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
ID: 9625125
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

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
countEvens challenge 2 116
has22 challenge 11 109
withoutTen challenge 14 140
"Black Box" Testing of Control System Software 2 125
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

739 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