Container Elements Are Copies

++ Primer 4/e在Sequence Container Operations這個地方有一個關鍵觀念:『When we add an element to a container, we do so by copying the element value into the container. Similarly, when we initialize a container by providing a range of elements, the new container contains copies of the original range of elements. There is no relationship between the element in the container and the value from which it was copied. Subsequent changes to the element in the container have no effect on the value that was copied, and vice versa.』

中文版的這樣寫:『當我們為容器添加元素時,是「把元素複製到容器」。同樣地,當我們提供某一區間元素來初始化容器時,新建容器所含的是原始區間元素的複件(副本)。容器內的元素和被複製的原始值之間沒有關聯。容器元素如果被改動,並不影響原始值;反之亦然。』

這個觀念我還覺很一般,所以就繼續保持這樣的觀念。

感謝你看到這裡,很快就可以離開了,但最好的獎勵行動就是按一下幫我分享或留言,感恩喔~

點我分享到Facebook

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *