Question 24: Which of the following template declarations provide the correct syntax to write a template class

来源:互联网 发布:php的正则表达式 编辑:程序博客网 时间:2024/05/22 17:34

template <class T> class Derived;

 

that has to inherit from another template class

 

template <class T> class Base;?

 

    A. template <class T, class Q> class Derived<Q> : public Base<T>

    where Q can be used as the templatized type for class Derived.

    B. template <class T, class Q> class Derived : public Base

    where Q can be used as the templatized type for class Derived.

    C. template <class T, class Q> class Derived : public Base<T>

    where Q can be used as the templatized type for class Derived.

    D. template <class T, class Q> class Derived<Q> : public Base

    where Q can be used as the templatized type for class Derived.

    E. template <class Q> class Derived<Q> : public Base

C

1. 模版类 申明和定义要写在一起

2. template <class T>
       class Derived : public Base<T>
       {
       };

    也是正确的

原创粉丝点击