如何将结构类型作为模板参数传递? [英] How to pass structure type as template argument?

查看:91
本文介绍了如何将结构类型作为模板参数传递?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这样的事情:



Something like this:

template <struct T>
class Foo {

};





该类将加载二进制文件并将其转换为给定的结构。

我找到了模板< class T>编译。这是正确的方式吗?



我尝试过:



上面的代码,以及搜索谷歌。到处都是结构类型,而不是我想要的。



The class is going to load binary file and cast it onto given structure.
I found template <class T> compiling. Is this proper way?

What I have tried:

The code above, and searching google as well. Everywhere struct type was actually defined, not as I wish.

推荐答案

T 只是真实的占位符将在您的源代码中稍后出现类foo的地方使用的类型。请参阅模板(C ++) [ ^ ]
T is just a placeholder for the real type that will be used wherever class foo appears later in your source code. see Templates (C++)[^]


这篇关于如何将结构类型作为模板参数传递?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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