久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 DLL 中使用類?

How to use a class in DLL?(如何在 DLL 中使用類?)
本文介紹了如何在 DLL 中使用類?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我可以將類放入 DLL 中嗎?我寫的課是這樣的:

Can I put a class inside a DLL? The class i wrote is this:

    class SDLConsole
{
      public:
             SDLConsole();
             ~SDLConsole(){};
             void getInfo(int,int);
             void initConsole(char*, char*, SDL_Surface*, int, int, int);
             void sendMsg(char*,int, SDL_Surface*);
             void cls(SDL_Surface*);

      private:
              TTF_Font *font;
              SDL_Surface *consoleImg;
              int width, pos, height, line, size, ctLine;
              SDL_Surface* render(char*,int);

};

我知道如何加載 DLL 并在 DLL 中使用該函數,但是如何將類放入 DLL 中?非常感謝.

I know how to load a DLL and use the function inside a DLL, but how can I put a class inside a DLL? Thank you very much.

推薦答案

如果使用運行時動態鏈接(使用 LoadLibrary 加載 dll)無法直接訪問該類,則需要為您的類聲明一個接口并創建一個返回此類實例的函數,如下所示:

If you use run time dynamic linking (uses LoadLibrary to load the dll) you cannot access the class directly, you need to declare a interface for your class and create a function that returns a instance of this class, like this:

class ISDLConsole
{
  public:             
         virtual void getInfo(int,int) = 0;
         virtual void initConsole(char*, char*, SDL_Surface*, int, int, int) = 0;
         virtual void sendMsg(char*,int, SDL_Surface*) = 0;
         virtual void cls(SDL_Surface*) = 0;
 };

 class SDLConsole: public ISDLConsole
 {
    //rest of the code
 };

 __declspec(dllexport) ISDLConsole *Create()
 {
    return new SDLConsole();
 }

否則,如果在加載時鏈接dll,只需使用icecrime 提供的信息:http://msdn.microsoft.com/en-us/library/a90k134d.aspx

Otherwise, if you link the dll during load time, just use the information provided by icecrime: http://msdn.microsoft.com/en-us/library/a90k134d.aspx

這篇關于如何在 DLL 中使用類?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 国产一区二区在线免费观看 | 国产99视频精品免视看9 | 精精精精xxxx免费视频 | av电影手机在线看 | 欧美在线a | av天天看 | 黄色网址免费在线观看 | 欧美日韩综合 | 一级一片在线观看 | 盗摄精品av一区二区三区 | 91精品国产色综合久久不卡蜜臀 | 久久亚洲一区二区三区四区 | 久久伊人一区二区 | 亚洲免费在线 | 成人亚洲一区 | 成人av一区| 亚洲一区国产精品 | 久久亚洲精品国产精品紫薇 | 国产精品欧美日韩 | 成人在线观看免费爱爱 | 国产日韩精品一区二区 | www.国产一区 | 国产日韩欧美激情 | 视频二区国产 | 久久久久久电影 | 一级特黄在线 | 国产91久久久久久久免费 | 一级免费毛片 | 成人在线免费视频观看 | 久久久国产一区二区三区 | 请别相信他免费喜剧电影在线观看 | 亚洲一区二区中文字幕 | 亚洲一区二区精品视频 | 精品久久久久久久久久久久久久久久久 | 亚洲欧洲日韩 | 成人精品高清 | 欧美视频免费在线 | 91热爆在线观看 | 日韩一区中文字幕 | 欧美日韩在线精品 | 一级毛片免费看 |