问题描述
以下内容似乎不属于以下类别:
模板< typename T>
class C {};
?
所以这是正式的考虑:一个类,一个模板,一个类模板,或者
a模板类?我一直认为它是一个参数化的类。什么
的理由是不将其视为班级?
-
Christopher Diggins
面向对象的模板库(OOTL)
It appears that the following is not considered a class:
template<typename T>
class C { };
?
So officially is this considered: a class, a template, a class template, or
a template class? I always thought of it as a parameterized class. What
would the rationale be for not considering it as just a ''class''?
--
Christopher Diggins
Object Oriented Template Library (OOTL)
http://www.ootl.org
推荐答案
这不是一个阶级,因为你可以''定义类型C的对象。它是
类模板,因为它定义了用于创建类的模式。
C< int>是一个班级。
-
Pete Becker
Dinkumware,Ltd。()
我看不出这样的理由。
显然,这是一个模板。什么类型的模板?...一个类模板(因为
反对,比如一个函数模板),因为它定义了一个类。
另外显然(对我来说),它是一个类,因为它定义了一个类。我不知道这是否是正确的术语,但我经常将其称为模板
类,如所描述的类通过模板。
但我相信正确的术语是类模板。
这个问题是因为一张海报建议在
标准C ++中没有字符串类吗?如果是这样,我会忽略这个陈述并继续处理。
从长远来看这可能是无关紧要的,只要有人你就是
沟通,了解你想说的话。
-Howard
I see no such rationale.
Obviously, it''s a template. What type of template?... a class template (as
opposed to, say, a function template), since it defines a class.
Also obviously (to me), it''s a class, since it defines a class. I don''t
know if it''s correct terminology, but I often refer to it as a template
class, as in "a class that is described by a template".
But I believe that the "correct" terminology is "class template".
Is this question because one poster suggested there was no string class in
standard C++? If so, I''d ignore that statement and get on with things.
It''s probably irrelevant in the long run, as long as someone you''re
communicating with understands what you''re trying to say.
-Howard
它不是一个class因为你不能定义C类对象。它是一个类
模板,因为它定义了一个用于创建类的模式。 ℃下INT>是一个
课。
It''s not a class because you can''t define objects of type C. It''s a class
template, because it defines a pattern for creating classes. C<int> is a
class.
好点。我同意,(并收回我的评论,C本身就是一个班级。)
-Howard
Good point. I agree, (and take back my remark that C itself is a class).
-Howard
这篇关于参数化类(即模板类/类模板)不是类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!