不需要导出类只有虚拟/内联函数? [英] Not necessary to export class with only virtual/inline functions?

查看:146
本文介绍了不需要导出类只有虚拟/内联函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Win32上的C ++中:

In C++ on Win32:

假设我有一个带有声明一个类的头文件的DLL。 DLL导出一些方法来获取指向该类的实例的指针/引用,例如工厂函数。

Suppose I have a DLL with a header file that declares a class. The DLL exports some means of obtaining a pointer/reference to an instance of that class, such as a factory function.

我认为没有必要使用__declspec标记该类为导出使用__declspec如果只在其实例上调用虚函数或内联函数?

Am I correct in believing that it is not necessary to mark that class as exported using __declspec if one is only going to call virtual or inline functions on its instances?

相反,如果有人希望导出类声明,调用非虚拟成员函数?

Conversely, is it necessary to export the class declaration if one wishes to call nonvirtual member functions?

推荐答案


我认为没有必要该类使用__declspec导出,如果只在其实例上调用虚函数或内联函数?

Am I correct in believing that it is not necessary to mark that class as exported using __declspec if one is only going to call virtual or inline functions on its instances?

这就是COM做什么,DLL只expotys 4方法,其中一个返回类工厂,其所有成员都是纯虚函数。

Yes,this is correct, and that's what COM do, the DLL only expotys 4 methods, one of them returns to the class factory, which all its members are pure virtual functions.


相反,如果想调用静态定义的成员函数,是否需要导出类声明?

Conversely, is it necessary to export the class declaration if one wishes to call statically defined member functions?

静态成员函数。

这篇关于不需要导出类只有虚拟/内联函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆