如何导出类函数,但不导出DLL中的整个类

Suj*_*osh 5 c++ dll c++-cli

我开发了一个Win32 DLL,提供了下面的详细信息,并希望为Connnect和LogOut函数创建一个CLI/C++包装器.

我知道可以从DLL导出整个类和函数.

class CClientLib
{
 public:
CClientLib (void);
// TODO: add your methods here.
__declspec(dllexport) bool Connect(char* strAccountUID,char* strAccountPWD);
__declspec(dllexport) void LogOut();

 private :

    Account::Ref UserAccount ;
void set_ActiveAccount(Account::Ref act)
{
   // Set the active account
}

Account::Ref get_ActiveAccount()
{
  return UserAccount;
    }

};
Run Code Online (Sandbox Code Playgroud)

我希望将类作为导出函数,Connect和LogOut,使用函数set/get.

是否只能导出函数Connect和LogOut,而不是整个类.

Tas*_*sos 10

我建议声明一个将被导出的接口,然后由内部类实现它.

class __declspec(dllexport) IClientLib {
 public:
    virtual bool Connect(char* strAccountUID,char* strAccountPWD) = 0;
    virtual void LogOut() = 0;
};

class CClientLib: public IClientLib {
...
};
Run Code Online (Sandbox Code Playgroud)