深拷貝拯救指針重複釋放(淺拷貝)造成的內存泄漏

淺拷貝以及內存泄漏的背景 先考慮一種情況,對一個已知對象進行拷貝,編譯系統會自動調用一種構造函數——拷貝構造函數,如果用戶未定義拷貝構造函數,則會調用默認拷貝構造函數 #include <iostream> #include "student.h" int main() { Student s1; Student s2(s1);//Student s2 = s1
相關文章
相關標籤/搜索