LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1030|回复: 3

哪位能给翻译一下这两句话,C++中的(英文),看不明白,谢了。

[复制链接]
发表于 2003-9-28 11:56:25 | 显示全部楼层 |阅读模式
An implementation that only makes unique copies when a string is modified is said to use a copy-on-write strategy. This approach saves time and space when strings are used only as value parameters or in other read-only situations.

Whether a library implementation uses reference counting or not should be transparent to users of the string class. Unfortunately, this is not always the case. In multithreaded programs, it is practically impossible to use a reference-counting implementation safely.

这是bruce eckel的thinking in c++卷二中的一段,介绍的是string类,第一段看明白了,是指当字符串要修改的时候才为另一个复制他的对象拷贝复本。第二段不明白,reference counting是什么意思啊?晕晕中,哪位帮忙给翻译或讲解一下,谢谢了。

不知道这贴发到这里合不合适,呵呵,不过常来linuxsir,就不想往别的地方发了,见谅。
发表于 2003-9-28 13:35:41 | 显示全部楼层
写时复制 这是一种技术 也就是如果不改变的话 对串值相同的STRING对象指向同一块内存

只有要改变某个STRING的内容时再复制出一份新的来

大概意思是这样
 楼主| 发表于 2003-9-28 14:20:27 | 显示全部楼层
谢谢无双,看了你的上面加注,现在搞明白了。
reference counting的意思好像是“引用计数”,应该指的是有多少string对象在指向同一段字符串。这段的大意应该如下:

仅当字符串被改变的时候才复制一个副本的实现方式被称为写时复制技术。当字符串被用作值参数或者用在只读环境中的时候,这种方法可以节省时间和空间。
对于字符串类,一个库的实现是否使用引用计数对用户来说应当是透明的。不幸的是,事实不总是这样。在多线程环境下,安全的使用引用计数实际是不可能的。
发表于 2003-9-28 19:28:16 | 显示全部楼层
是的
你翻译得很准确
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表