由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Please help on Effective C++ Item 11
相关主题
请教一个C++问题小公司web server面经
c++ class default functions?还是基础题
请教一个C++的题目,谢谢BB phone interview question
问一个constructor的问题请问这个C++问题对吗?
问几个跟C++有关的面试题C++ Q47: protected constructor (C39)
发发我自己的Bloomberg的面经an old c++ question
One C++ question贡献点g家电面题
C++ Q61: 如何对const data member做assignment?问一个smart pointer的问题
相关话题的讨论汇总
话题: item话题: string话题: c++话题: effective话题: construct
进入JobHunting版参与讨论
1 (共1页)
w******0
发帖数: 43
1
The author in Item 11, said something about copy and assignment constructor
In following code, last line ,the author said a.data is already deleted
but I wrote a program, and did test. find the value is still there. thanks.
String a("Hello"); // define and construct a
{ // open new scope
String b("World"); // define and construct b
...
b = a; // execute default op=,
f****4
发帖数: 1359
2
Effective C++ Item 11 没看到你这个例子
但是,new scope里面的string b在出scope之后delete了,而不是a
w******0
发帖数: 43
3
hi Brother,
Yes, It has.
Item 11: Declare a copy constructor and an assignment operator for classes
with dynamically allocated memory.
Just because b out of scope, b was deleted.
we have b = a;
so b.data point to a.data
b delete, b.data and a.data was deleted too.
so the author said a.data is already deleted
but I use cout, it can print out a.data. weird.

【在 f****4 的大作中提到】
: Effective C++ Item 11 没看到你这个例子
: 但是,new scope里面的string b在出scope之后delete了,而不是a

z****e
发帖数: 2024
4
兄台,贴代码。String的实现。
g**********1
发帖数: 1113
5
string 和 String差别很大。不要搞混了
1 (共1页)
进入JobHunting版参与讨论
相关主题
问一个smart pointer的问题问几个跟C++有关的面试题
一个Naive的问题,tree的destruction发发我自己的Bloomberg的面经
Qualcomm Phone Interbview面筋,赚RPOne C++ question
贴一道take home的面试题C++ Q61: 如何对const data member做assignment?
请教一个C++问题小公司web server面经
c++ class default functions?还是基础题
请教一个C++的题目,谢谢BB phone interview question
问一个constructor的问题请问这个C++问题对吗?
相关话题的讨论汇总
话题: item话题: string话题: c++话题: effective话题: construct