DLL导出类而不添加其头文件 [英] DLL exporting a class without adding its header file

查看:298
本文介绍了DLL导出类而不添加其头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想dllexport一个类来访问其指针和成员函数.是否有任何方法可以在不添加该类的头文件的情况下进行?

解决方案

确实不需要头文件来导出一个类,但是您需要类声明来 import 以是否以头文件的形式导入它.不使用头文件是没有意义的,并且非常不方便,因为您需要在一个以上的C ++文件中使用声明.

—SA


是的:您可能发明了COM.


您并不需要头文件,但您确实需要通常在头文件中的类定义(没有该类,则无法编译).
通常,头文件包含类定义所需的其他包含,例如如果成员变量之一的类型为HWND,则为windows.h.

如果您不能添加头文件的原因是它给出了编译错误,则可以尝试复制类定义,并仅包含所需的文件,然后跳过其余的文件.


Hi,

I want to dllexport a class for acessing its pointers and member functions.Is there any way of doing it without adding that class''s header file?

解决方案

You don''t really need a header file to export a class, but you need the class declaration to import it, in the form of header file or not. Not using header files makes no sense and would be extremely inconvenient is you need to use the declaration in more then one C++ file.

—SA


Yes: you might invent COM.


You don''t specifically need the header file, but you do need the class definition which is typically in the header file (without this, you can''t compile).
Usually, the header file contains additional includes which are required for the class definition, f.e. windows.h if one of the member variables has type HWND.

If the reason you can''t add the header file is that it gives a compile error, you could try copy the class definition and include only the files needed for that and skip the rest.


这篇关于DLL导出类而不添加其头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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