精華區beta Programming 關於我們 聯絡資訊
※ 引述《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 行為是否符合自己的需求。 -- 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-172.dynamic.hinet.net ─╨─╨─ KGBBS 遨翔"BBS"的狂狷不馴;屬於年少的輕狂色彩