Kao, 20 yr experience in cpp and 30 yr experience in c ... Just ask him a lot of questions about pointer: raw pointer, all kinds of smart pointer (intrusive, shared, auto, strong ref , weak ref, .... ) And some related issues like array, reference, new, new[], placement new, malloc, blahblah. Perhaps the best queston is what's the diff between c and c++. Actually this is a question hard to me and I don't know how to answer it in short words.
I'm wondering if you should use delete[] s; And what if we do Stack s; and then s.push(3). Then the stack never gets doubled and you get a seg fault. Am I right?
【在 j****i 的大作中提到】 : I'm wondering if you should use : delete[] s; : And what if we do Stack s; and then s.push(3). Then the stack never gets : doubled and you get a seg fault. : Am I right?
P*e
66 楼
primitive data type尽量不要用member initialization list this complicate compiler when it's get to call member functions in ctor
【在 j****i 的大作中提到】 : I'm wondering if you should use : delete[] s; : And what if we do Stack s; and then s.push(3). Then the stack never gets : doubled and you get a seg fault. : Am I right?
P*e
69 楼
我说的不完全, 应该这样说,primitive data type放 init list没有区别和放ctor body 不过compiler declare all members before any user code 所以,如果 A: foo ( i ), j (i)这种情况,最好都放ctor body 否则有问题
【在 P********e 的大作中提到】 : 我说的不完全, 应该这样说,primitive data type放 init list没有区别和放ctor : body : 不过compiler declare all members before any user code : 所以,如果 A: foo ( i ), j (i)这种情况,最好都放ctor body : 否则有问题
【在 P********e 的大作中提到】 : 我找了个inside c object model,其实是很吹毛求疵的东西
j*i
78 楼
3天看完的.理解的了不? 很快久忘光了把
【在 z****e 的大作中提到】 : inside c object model 很多implementation dependent的东西,编译器的实现都是不 : 一样的,看该书有点浪费时间。 : 我花了3天看完,感觉收获一般,付出时间和收获不太成比例。 : 但是信心增强。
z*e
79 楼
我是3天,每天12小时啊。36个小时还看不完么?
【在 j***i 的大作中提到】 : 3天看完的.理解的了不? 很快久忘光了把
t*t
80 楼
you don't have to change default capacity to 1, because (a) it's a waste if you declare a lot of empty containers (b) the default capacity may be changed anyway, you can't prevent user to send in a 0 capacity. the answer is obvious, when you double the capacity, check whether it is 0 first!
麻烦你先学学怎么说中文吧. "primitve data type放init list和放ctor body没有区别" "否则有问题", 有什么问题呢?
【在 P********e 的大作中提到】 : 我说的不完全, 应该这样说,primitive data type放 init list没有区别和放ctor : body : 不过compiler declare all members before any user code : 所以,如果 A: foo ( i ), j (i)这种情况,最好都放ctor body : 否则有问题
j*i
82 楼
多谢了. 一时没转过来.
if
【在 t****t 的大作中提到】 : you don't have to change default capacity to 1, because (a) it's a waste if : you declare a lot of empty containers (b) the default capacity may be : changed anyway, you can't prevent user to send in a 0 capacity. : the answer is obvious, when you double the capacity, check whether it is 0 : first!
j*i
83 楼
Thanks!
if
【在 t****t 的大作中提到】 : you don't have to change default capacity to 1, because (a) it's a waste if : you declare a lot of empty containers (b) the default capacity may be : changed anyway, you can't prevent user to send in a 0 capacity. : the answer is obvious, when you double the capacity, check whether it is 0 : first!