继承模板类 [英] Inheriting template class
本文介绍了继承模板类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道这是否有效。我有一个模板库
类,我希望能够继承,类b / b需要继承的类也需要进行tamplates。这有可能
或者我需要考虑另一种方法吗?
I am trying to figure out if this will work. I have a template base
class that I want to be able to inherit from, the classes that will
need to inherit from this also need to be tamplates. Is this possible
or do i need to think of another way to do it?
推荐答案
jarr ... @ gmail.com写道:
jarr...@gmail.com wrote:
我试图弄清楚这是否有效。我有一个模板库
类,我希望能够从中继承,需要从中继承的类也需要进行tamplates。这可能吗?或者我需要考虑另一种方法吗?
I am trying to figure out if this will work. I have a template base
class that I want to be able to inherit from, the classes that will
need to inherit from this also need to be tamplates. Is this possible
or do i need to think of another way to do it?
模板< typename X>
class C1
{
};
模板< typename Y>
类C2:公共C1< ; Y>
{
Y var;
};
只是一种方式这样做,满足一系列特定的需求。
template<typename X>
class C1
{
};
template<typename Y>
class C2 : public C1<Y>
{
Y var;
};
is but one way of doing it, meeting a particular set of needs.
嗯我试过了,我得到一个错误,说C2不是模板
名称
Hmm I tried that and I get an error saying that C2 is not a template
name
更正不是模板类型
correction not a template type
这篇关于继承模板类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文