参数化类(即模板类/类模板)不是类? [英] A parameterized class (i.e. template class / class template) is not a class?

查看:102
本文介绍了参数化类(即模板类/类模板)不是类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下内容似乎不属于以下类别:


模板< typename T>

class C {};





所以这是正式的考虑:一个类,一个模板,一个类模板,或者

a模板类?我一直认为它是一个参数化的类。什么

的理由是不将其视为班级?


-

Christopher Diggins

面向对象的模板库(OOTL)
http:// www .ootl.org

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

推荐答案

christopher diggins写道:
christopher diggins wrote:
看来以下不被认为是class:

模板< typename T>
C类{};



所以正式考虑这个:一堂课,模板,类模板或模板类?我一直认为它是一个参数化的类。理由是什么不考虑它只是一个阶级?
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''?




这不是一个阶级,因为你可以''定义类型C的对象。它是
类模板,因为它定义了用于创建类的模式。

C< int>是一个班级。


-


Pete Becker

Dinkumware,Ltd。( http://www.dinkumware.com




" christopher diggins" < CD ****** @ videotron.ca>在消息中写道

新闻:CO ********************* @ wagner.videotron.net。 ..

"christopher diggins" <cd******@videotron.ca> wrote in message
news:CO*********************@wagner.videotron.net. ..
看来以下不被视为一个类:


由谁?

模板< typename T>
C类{};



所以正式考虑的是:类,模板,类模板,模板类?我一直认为它是一个参数化的类。什么
理由是不将它视为阶级?
It appears that the following is not considered a class:

By whom?
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''?




我看不出这样的理由。


显然,这是一个模板。什么类型的模板?...一个类模板(因为

反对,比如一个函数模板),因为它定义了一个类。


另外显然(对我来说),它是一个类,因为它定义了一个类。我不知道这是否是正确的术语,但我经常将其称为模板

类,如所描述的类通过模板。


但我相信正确的术语是类模板。


这个问题是因为一张海报建议在

标准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




Pete Becker < PE ******** @ acm.org>在消息中写道

新闻:-M ******************** @ rcn.net ...

"Pete Becker" <pe********@acm.org> wrote in message
news:-M********************@rcn.net...
christopher diggins写道:
christopher diggins wrote:
看来以下不被认为是一个类:

模板< typename T>
class C {};



所以这是正式的考虑:一个类,一个模板,一个类模板,
还是一个模板类?我一直认为它是一个参数化的类。
不考虑它只是一个阶级的理由是什么?
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''?



它不是一个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


这篇关于参数化类(即模板类/类模板)不是类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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