验证 vector = 是深拷贝还是浅拷贝


#include <vector>
using namespace std;
int main()
{
	int w=1920;
	int h = 1080;
	vector<int> dataA( w*h ,0Xff);

	vector<int> dataB = dataA;

	int * ptr0 = &dataA[0];
	int * ptr1 = &dataB[0];

	printf( "%u\n",ptr0 );
	printf("%u\n", ptr1);

	return 0;
}

output:

959246464
967577728

 

两者数据指针地址不同 ,  所以是深拷贝!!!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM