如何创建一些类从dll(构造函数在dll)?(с++) [英] How to create some class from dll(constructor in dll)?(с++)

查看:114
本文介绍了如何创建一些类从dll(构造函数在dll)?(с++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从dll(dll中的构造函数)创建一些类?(с++)
或如何从dll动态加载类

How to create some class from dll(constructor in dll)?(с++) or how to dynamically load class from dll?

推荐答案

严格回答你的问题,你需要添加一个externC函数返回构造函数的结果:

Answering your question strictly, you need to add an extern "C" function that returns the result of the constructor:

extern "C" foo* __declspec(dllexport) new_foo(int x) {
    return new foo(x);
}

然后在你的源代码中你可以使用GetProcAddrnew_foo 。

Then in your source you can use GetProcAddr on "new_foo" to call the function.

这篇关于如何创建一些类从dll(构造函数在dll)?(с++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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