gpt4 book ai didi

c++ - 如何从 DLL 导出模板?

转载 作者:行者123 更新时间:2023-11-30 01:19:36 29 4
gpt4 key购买 nike

我可以从 DLL 导出模板吗?

我想从 DLL 中导出这样的函数?

template <class T1,class T2)
T1 Create(T2 parameter)
{
T1 retvalue=new T1();
retvalue.process(parameter);
// do some other work
return T1;
}

我可以这样做吗?

如果不行,请问还有其他办法吗?我的意思是从用户定义的类型创建一个对象?

最佳答案

您不能从 DLL 导出模板。当模板被实例化时,编译器需要能够看到所有的源代码。

关于c++ - 如何从 DLL 导出模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20677277/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com