C++深拷貝與淺拷貝

淺拷貝  所謂淺拷貝,指的是在對象複製時,只對對象中的數據成員進行簡單的賦值,默認拷貝構造函數執行的也是淺拷貝 class Rect { public: Rect(){ count++; cout<<count<<endl; } //構造函數,計數器加1 //拷貝構造函數 /*Rect(const Rect &r) *{ * width = r.width; * height = r.height
相關文章
相關標籤/搜索