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

相关文章:

  • 2022-01-30
  • 2022-12-23
  • 2021-07-27
  • 2021-11-20
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-05
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
相关资源
相似解决方案