首页 > 其他 > 详细

标准库std::string写时拷贝

时间:2015-11-01 16:25:05      阅读:303      评论:0      收藏:0      [点我收藏+]
#include<string>
#include<cstdio>
int main()
{
	std::string str1 = "Hello";
	std::string str2 = str1;
	printf("str1:%x\n",str1.c_str());
	printf("str2:%x\n",str2.c_str());
	str1[1]=‘Q‘;
	str2[1]=‘W‘;
	printf("str1:%x\n",str1.c_str());
	printf("str2:%x\n",str2.c_str());
	return 0;
}

运行结果:

str1:56133c
str2:56133c
str1:56135c
str2:56133c

 

文章来自:陈皓博客:http://blog.csdn.net/haoel/article/details/24058

标准库std::string写时拷贝

原文:http://www.cnblogs.com/tylerhuang/p/4927836.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!