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
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
353 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
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.

808 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