精華區beta Programming 關於我們 聯絡資訊
※ 引述《UNARY.bbs@bbs.cse.ttu.edu.tw (Rootkit Researcher)》之銘言: > ※ 引述《tinlans.bbs@whshs.cs.nccu.edu.tw (汀)》之銘言: > > 這叫 copy assignment, > > 相當於把 box1 裡的三個 data members, > > 一個 bit 一個 bit 的複製到 box2 的三個 data members 裡去, > > 這又叫 bitwise copy, > > 因為你沒有設計 copy assignment operator 給 CBox, > > 裡面的 data members 又都是 primitive types, > > 所以預設是 bitwise copy。 > > 在 data members 中有 pointer 時, > > 要特別留意這種 default 行為是否符合自己的需求。 > copy assignment operator?? > "CBox box2 = box1;" 這個是呼叫 box2 的 (copy) constructor 吧? 看太快看錯了, 是 copy constructor, 跟定義式分開寫的才叫 copy assignment operator, 所以前文請板友自行做字串代換, 其它觀念部分不變。 -- Name: Tseng, Ling-hua E-mail Address: uranus@it.muds.net School: National Tsing Hua University Department: Computer Science Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design Researching: Undecided Homepage: https://it.muds.net/~uranus -- ╔═══╗ ┼────────────────────────╮ 狂狷 Origin:[ 狂 狷 年 少 ] whshs.cs.nccu.edu.tw ╰─╮ 年少 ┼╮ < IP:140.119.164.252 > ╰─╮ ╚╦═╦╝ From:61-230-224-108.dynamic.hinet.net ─╨─╨─ KGBBS 遨翔"BBS"的狂狷不馴;屬於年少的輕狂色彩