先考慮一種情況,對(duì)一個(gè)已知對(duì)象進(jìn)行拷貝,編譯系統(tǒng)會(huì)自動(dòng)調(diào)用一種構(gòu)造函數(shù)——拷貝構(gòu)造函數(shù),如果用戶未定義拷貝構(gòu)造函數(shù),則會(huì)調(diào)用默認(rèn)拷貝構(gòu)造函數(shù)

復(fù)制代碼
//main.cpp  #include <iostream> #include "student.h" int main()
{
         Student s1;
         Student s2(s1);//Student s2 = s1;//復(fù)制對(duì)象 return 0;
}
復(fù)制代碼