开发者

how to use a c++ class that is exported to a dll?

I have exported a C++ class and now i want to use its public member function. how i can do it?

I want to have dynamic binding. My exported class looks like this

#ifdef MAKEDLL
#define DECLDIREXP __declspec(dllexport)
#else
#define DECLDIREXP __declspec(dllimport)
#endif

class DECLDIREXP xyz 
{
public: 
    void printing(); 
    vo开发者_如何转开发id printing(int a);
};  

using namespace std; 

void xyz::printing()
{
    cout<<"hello i donot take any argument";
}

void xyz::printing(int a)
{
    cout<<"hello i take "<< a <<"as argument";
}


it seems you are almost there. When building the project generating the dll, make sure MAKEDLL is defined for the linker, and the other way round in projects consuming the dll.

By the way MAKEDLL is probably a bad Name, but MAKEFOODLL if your dll is called foo a better one

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜