zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    面向对象程序设计寒假作业2
    面向对象程序设计寒假作业1
    自我介绍
    3组-Alpha冲刺-1/6
    3组 需求分析报告
    3组 团队展示
    第一次个人编程作业
    第一次博客作业
    我罗斯方块最终篇
    我罗斯方块设计
  • 原文地址:https://www.cnblogs.com/ahuo/p/3130184.html
Copyright © 2011-2022 走看看