如何声明模板类的模板 [英] how to declare template of template class

查看:186
本文介绍了如何声明模板类的模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何声明模板类的模板?请参阅以下代码:

How can declare template of a template class?? see below code:

File: A.h
class A
{
    ...
    ...
};

File: B.h
template <typename U>
class B
{
    ...
    ...
};

File C.h
template <class T>
class C
{
    ...
    ...
};

File C.cpp
//In this file I am able to write template declaration for class A(non-template class)
#include "A.h"
template C<A>; //this works fine. 

How can I write the same for class B(which is a template class.)
#include "B.h"
template C<What should I write here for class B?>;


推荐答案

好吧,B也是一个模板, C< B< A>< / code>将工作。

Well, B is also a template, so something like C<B<A>> would work.

注意,一些编译器看到 >>< / code>作为移位运算符,并且需要 C

Note that some compilers see >> as a shift operator, and requires C<B<A> >.

这篇关于如何声明模板类的模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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