久久久久久久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一级毛片 | 午夜精品一区二区三区三上悠亚 | 一区在线免费视频 | 国产98色在线 | 日韩 | www.youjizz.com日韩 | 一区二区不卡视频 | 北条麻妃一区二区三区在线视频 | 日韩在线视频免费观看 | 欧美日韩三级 | 狠狠久久 | 一级毛片视频在线 | 国产精品一区二区久久久久 | jvid精品资源在线观看 | 97精品国产 | 日日夜夜av| 亚洲一区国产 | 一区二区小视频 | 亚洲一区视频在线 | 国产日韩精品一区二区 | 久久久久久久久久性 | 日本不卡高清视频 | 天天干天天谢 | 91私密视频 | 中文字幕精品视频 | 中文在线一区二区 | 欧美日韩成人影院 | 亚洲 精品 综合 精品 自拍 | 精品久久网 | 麻豆av在线免费观看 | 成人欧美一区二区三区在线播放 | 国产精品夜色一区二区三区 | 麻豆国产一区二区三区四区 | 日本网站在线看 | 国产乱精品一区二区三区 | 久久高清亚洲 | 一区二区三区国产精品 | 精品国产91乱码一区二区三区 | 欧美色综合 | 国产精品久久久久久久久久久久久久 | 久久午夜国产精品www忘忧草 | 中文字幕蜜臀 |