将类导出到DLL [英] exporting classes to DLLs
问题描述
hello现在有点困惑与DLL现在,所以我来到这里问,在那里有大量的编程的优点在
所以这个类叫GUI.h和GUI.cpp
hello im a bit confused with DLLs right now so i came here to ask where there are alot of pros in programming so ive got this class called GUI.h and the GUI.cpp
class GUI
{
public:
GUI(void);
virtual ~GUI();
void Draw(float x,float y,float z);
void Texture(int num);
bool Shutdown();
void TextureON(int num);
void TextureOFF(int num);
private:
GUIWeapon * Weapon;
GUIWeaponA * Weapona;
GUIArrow * Arrow;
GUIHP * hp;
GUIStop * stop;
GUISpeed * Speed;
float XCam,YCam,ZCam;
bool DrawStop;
};
所以我不知道如何导出这个DLL我已经做了DLL,但没有类,我不能声明构造函数,析构函数并调用其他头部中的其他GUIFunctions?
so how am i suppossed to export this to a DLL i have made DLLs but not with classes so how am im suppossed to declare the Constructor,Destructor and call the other GUIFunctions in other headers?
推荐答案
或操作系统,但如果这是Windows和Microsoft C ++,那么您可以在类上使用__declspec(dllexport)将其从DLL导出。然后,当您包括要在其他地方使用的标头时,在同一个类上使用__declspec(dllimport)。
You don't specify a compiler or operating system, but if this is Windows and Microsoft C++, then you can use __declspec(dllexport) on a class to export it from a DLL. You then use __declspec(dllimport) on the same class when you include the header to be consumed elsewhere.
但是,我倾向于建议不要从DLLs导出类。这是一个好的计划,如果所有的DLL总是一起运输,并建立在一起。 [其中DLL只是用于延迟加载代码]。如果您使用DLL来提供单独运送的实际组件,您应该使用像COM这样的实际版本抽象。
However, I tend to recommend against exporting classes from DLLs. It's an ok plan if all the DLLs always ship together and are built together. [Where the DLL is just used to delay loading of code]. If you are using DLLs to provide actual components that ship separately, you should use an actual versionable abstraction like COM.
Martyn
这篇关于将类导出到DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!