下面有两个问题,请指教

lettermail6 2003-09-12 10:36:55
第一问
template<class T, class A = allocator<T> >
这个定义类模板, 请具体点说一下它们的含义。特别是后面那部分


第二问:帮我翻译一下下面这段话里有话
A namespace declaration identifies and assigns a name to a declarative region.
...全文
78 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
akun 2003-09-12
  • 打赏
  • 举报
回复
1. template<class T, class A = allocator<T> >
第一个参数是传入类型,第2个参数传入另外一个类型,缺省是一个allocator<T>
allocator也是一个模板类,模板参数是T.

2. 真tm难翻,意会不能言传~~~~~ ^o^!!
sandrowjw 2003-09-12
  • 打赏
  • 举报
回复
声明一个名字空间(可以)标示一个声明区并给它一个名字。
allenhai1980 2003-09-12
  • 打赏
  • 举报
回复
类似定义方式:
template<typename T, typename Allocator = allocator<T>>
第二个参数缺省。详见MSDN中allocator模板类的定义。
allenhai1980 2003-09-12
  • 打赏
  • 举报
回复
namespace [identifier] { namespace-body }

A namespace declaration identifies and assigns a name to a declarative region.
The identifier in a namespace declaration must be unique in the declarative region in which it is used. The identifier is the name of the namespace and is used to reference its members.
The declarative region of a namespace declaration is its namespace-body.

一句白话:
namespace [identifier] { namespace-body } 的作用是:
identifier 成为 namespace-body 的名字。呵呵。


allenhai1980 2003-09-12
  • 打赏
  • 举报
回复
template<class T>
class allocator { };
详见MSDN中template class allocator的说明。
class A传入另外一个类型,她有一个缺省赋值:allocator<T>

2。
namespace [identifier] { namespace-body }

A namespace declaration identifies and assigns a name to a declarative region.

The identifier in a namespace declaration must be unique in the declarative region in which it is used. The identifier is the name of the namespace and is used to reference its members.
The declarative region of a namespace declaration is its namespace-body.

一句大白话:声明名空间也就是给了这个名空间的名空间体一个名字。
namespace [identifier] { namespace-body }:identifier 就是 namespace-body 的名字。呵呵。

FAICHEN 2003-09-12
  • 打赏
  • 举报
回复
给一个声明为命名空间的这块区域定义并且分配一个名字
lettermail6 2003-09-12
  • 打赏
  • 举报
回复
不够详细啊
1. template <class T, class A = allocator <T > >

allocator也是一个模板类,模板参数是T. ----这个理解
若把它写成 template <class T, class A> 我也理解。就是这个模板有两个参数 T和A
但是class A=allocator 我不知道是什么意思

lettermail6 2003-09-12
  • 打赏
  • 举报
回复
up 啊兄弟们

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧