精華區beta Programming 關於我們 聯絡資訊
※ 引述《tinlans.bbs@whshs.cs.nccu.edu.tw (汀)》之銘言: > ※ 引述《quota@kkcity.com.tw (我要出清)》之銘言: > > CBox box1(78.0, 24.0, 18.0); > > CBox box2 = box1; > > 請問我的box2是不是就是box1這個物件呢? > > 謝謝 > 這叫 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 吧? -- , 秘密情人 (bbs.cse.ttu.edu.tw) ~\ Post From: 220-136-192-28.dynamic.hinet.net Modify: 2006/10/27 Fri 21:17:10