Cpp8 运算符重载和深浅拷贝
深浅拷贝 相同类型间可以直接拷贝 // _20180212.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include class A { private: int* a; public: A() { a = new int[10]; } virtual ~A() { delete a; printf("析构 A \n"); } }; int main(int argc,char* argv[]) { A a1; A a2; a1 = a2; return 0; } //反汇编 27: A a1; 0040108D lea ecx,[ebp-14h] 00401090 call @ILT+15(B::B) (00401014) 00401095 mov dword ptr [ebp-4],0 28: A a2; 0040109C lea ecx,[ebp-1Ch] 0040109F call @ILT+15(B::B) (00401014) 004010A4 mov byte ptr [ebp-4],1 29: a1 = a2; 004010A8 lea eax,[ebp-1Ch] 004010AB push eax //a2 作为参数传递 004010AC lea ecx,[ebp-14h] //a1……