vc DLL 隐藏成员和内部类

//MDLL.h
#include "If.h"
typedef struct _SS
{
 int a;
 int b;
}SS;
class  CMDLL :public IfC
{
public:
    CMDLL(void);
    int a()
    {
        SS s;
        x=30;
        s.a=10;
        return s.a;
    }
    int b()
    {
        return 20;
    }
    int hh;
};

//Fa.h
#include "If.h"

class MDLL_API CFa

{
public:
CFa(void);
~CFa(void);
public:
static IfC *GetP();
static void Destroy();
private:
static IfC *pIfC;
};


//Fa.cpp

#include "MDLL.h"
#include "Fa.h"

IfC* CFa::pIfC=NULL;
CFa::CFa(void)
{
}


CFa::~CFa(void)
{
}

IfC * CFa::GetP()
{
if(!pIfC)
{
pIfC = new CMDLL(); 
}
return pIfC;
}

void CFa::Destroy()
{
if(pIfC)
delete pIfC;
}

//Ifc.h
#ifdef MDLL_EXPORTS
#define MDLL_API __declspec(dllexport)
#else
#define MDLL_API __declspec(dllimport)
#endif


 class MDLL_API IfC{
 public:
	virtual int a()=0; // 这个我希望对dll使用者可见
 int x;
 int y;
};




int _tmain(int argc, _TCHAR* argv[])
{
	IfC* c=CFa::GetP();
	printf("%d\n",c->a());
	printf("%d",c->x);
	return 0;
}

 

  https://files.cnblogs.com/ahuo/IDLL.rar

posted @ 2013-06-09 23:00  ahuo  阅读(395)  评论(0编辑  收藏  举报