模拟实现string类深浅拷贝

上传:sinat_40317 浏览: 14 推荐: 0 文件:PDF 大小:74.08KB 上传时间:2021-01-15 06:06:14 版权申诉
从构造,析构以及拷贝构造的方面理解string类的底层实现。 源代码获取: https://github.com/akh5/C-/blob/master/STL/Mystring.cpp string的底层通过字符指针char*通过构造函数申请对应大小的空间,并将指针指向其空间。 #include #include #include namespace my { class string { public: string(char* str = ) { if (nullptr == str) str = ; //申请空间 _str = new
上传资源
用户评论