C ++ / CLI:对模板类型公开 [英] C++/CLI: make public for template type

查看:169
本文介绍了C ++ / CLI:对模板类型公开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AFAIK #pragma make_public 只支援原生非模板类型。

AFAIK #pragma make_public supports only native non-template types.

要使模板类型为public?

But, is there some other way to make template type as public?

推荐答案

模板没有外部链接。不是在本机C + +,不是在C + + / CLI。你用同样的方法解决它,把它们放在一个.h头文件中,并将它包含在你想使用模板的任何源文件中。它们当然不适用于不是用C ++ / CLI编写的任何其他托管代码。

Templates don't have external linkage. Not in native C++, not in C++/CLI either. You solve it the same way, put them in a .h header file and #include it in any source file where you want to use the template. They are of course not available to any other managed code that isn't written in C++/CLI.

赞成C ++中的通用关键字/ CLI,托管代码中的泛型 do 具有等价的外部链接。

Do favor the generic keyword in C++/CLI, generics in managed code do have the equivalent of external linkage.

这篇关于C ++ / CLI:对模板类型公开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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