由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Effective C++ 这破书!
相关主题
/usr/bin/ld: Undefined symbols:[合集] 请牛人解释为啥C++ has stronger typing than C//bow
问个C++的operator conversation function问题[合集] c++的dynamic_cast是如何实现的?
The untold truth about C++C++0x
Question on C++ Access Control (protected)读Bjarne Stroustrup写得The C++ programming language 是不是经常有不知所谓的感觉。
C++,大家觉得最值得买最想买最不后悔买的书是哪本?(zz)C++11新特性
VB, C++初学者清推荐书籍这么好的帖子没人转?
question about const reference有必要开个c++版
哪位大侠有如下书籍的电子版,或者下载地址,多谢Bjarne Stroustrup C++第四版电子版出来了
相关话题的讨论汇总
话题: widget话题: c++话题: rhs话题: effective话题: operator
进入Programming版参与讨论
1 (共1页)
S****z
发帖数: 666
1
首先说 operator= (const Widget& rhs) //pass by ref
用引用可以省copy constructor
但是在下面一章的handle assignment to self in operator=
又说为了making operator= exception-safe
要用copy and swap技术
所以要把operato=定义为
Widget& Widget::operator=(Widget rhs) //pass by value
{
swap(rhs); //swap *this's data with the copy's
return *this;
}
一时说pass by ref一时又说pass by value
这样墙头草的书不读也罢!!
我太阳!
p***o
发帖数: 1252
2
You don't get the point. He first showed you a typical textbook solution,
which is difficult to get exception safe (and most textbook writers don't
understand what is exception safe), and then showed you the copy-and-swap
idiom, which is simple and exception safe.

【在 S****z 的大作中提到】
: 首先说 operator= (const Widget& rhs) //pass by ref
: 用引用可以省copy constructor
: 但是在下面一章的handle assignment to self in operator=
: 又说为了making operator= exception-safe
: 要用copy and swap技术
: 所以要把operato=定义为
: Widget& Widget::operator=(Widget rhs) //pass by value
: {
: swap(rhs); //swap *this's data with the copy's
: return *this;

S****z
发帖数: 666
3
原来这书作者是在BSO它自己的safe而其他书的不safe是吧
好吧,这次忍了,再往下读读看
BTW:貌似还有本叫More Effective C++?既然它叫More Effective
那More的作者应该比这个没有More的更牛叉吧,我是不是直接读那本就行了
没必要在这本没有More的上浪费时间?

【在 p***o 的大作中提到】
: You don't get the point. He first showed you a typical textbook solution,
: which is difficult to get exception safe (and most textbook writers don't
: understand what is exception safe), and then showed you the copy-and-swap
: idiom, which is simple and exception safe.

S*********g
发帖数: 5298
4
太浪费时间了。牛人都不看书,直接自己拍脑袋整一个C++,譬如stroustrup

【在 S****z 的大作中提到】
: 原来这书作者是在BSO它自己的safe而其他书的不safe是吧
: 好吧,这次忍了,再往下读读看
: BTW:貌似还有本叫More Effective C++?既然它叫More Effective
: 那More的作者应该比这个没有More的更牛叉吧,我是不是直接读那本就行了
: 没必要在这本没有More的上浪费时间?

b******n
发帖数: 592
5
所以才是个半成品。。编程语言真没有好用的。。。

【在 S*********g 的大作中提到】
: 太浪费时间了。牛人都不看书,直接自己拍脑袋整一个C++,譬如stroustrup
S****z
发帖数: 666
6
原来是这个叫stroustrup弄出来的
我对C++很不满,有他的email吗?我要complain!

【在 S*********g 的大作中提到】
: 太浪费时间了。牛人都不看书,直接自己拍脑袋整一个C++,譬如stroustrup
S****z
发帖数: 666
7
怪不得我怎么感觉那么不爽,原来是半成品

【在 b******n 的大作中提到】
: 所以才是个半成品。。编程语言真没有好用的。。。
t****t
发帖数: 6806
8
这坑太烂了, 打回重挖.

【在 S****z 的大作中提到】
: 首先说 operator= (const Widget& rhs) //pass by ref
: 用引用可以省copy constructor
: 但是在下面一章的handle assignment to self in operator=
: 又说为了making operator= exception-safe
: 要用copy and swap技术
: 所以要把operato=定义为
: Widget& Widget::operator=(Widget rhs) //pass by value
: {
: swap(rhs); //swap *this's data with the copy's
: return *this;

z****e
发帖数: 2024
9
作者写的挺清楚的,打回去重读。

【在 S****z 的大作中提到】
: 首先说 operator= (const Widget& rhs) //pass by ref
: 用引用可以省copy constructor
: 但是在下面一章的handle assignment to self in operator=
: 又说为了making operator= exception-safe
: 要用copy and swap技术
: 所以要把operato=定义为
: Widget& Widget::operator=(Widget rhs) //pass by value
: {
: swap(rhs); //swap *this's data with the copy's
: return *this;

g*******e
发帖数: 3013
10
Effective Java 这本书不错(看亚马逊评价)。改看这本吧。;)

【在 S****z 的大作中提到】
: 首先说 operator= (const Widget& rhs) //pass by ref
: 用引用可以省copy constructor
: 但是在下面一章的handle assignment to self in operator=
: 又说为了making operator= exception-safe
: 要用copy and swap技术
: 所以要把operato=定义为
: Widget& Widget::operator=(Widget rhs) //pass by value
: {
: swap(rhs); //swap *this's data with the copy's
: return *this;

相关主题
VB, C++初学者清推荐书籍[合集] 请牛人解释为啥C++ has stronger typing than C//bow
question about const reference[合集] c++的dynamic_cast是如何实现的?
哪位大侠有如下书籍的电子版,或者下载地址,多谢C++0x
进入Programming版参与讨论
m***i
发帖数: 2480
11
My company C++ style guide: Neither operator overloading nor exception is
allowed.

【在 S****z 的大作中提到】
: 首先说 operator= (const Widget& rhs) //pass by ref
: 用引用可以省copy constructor
: 但是在下面一章的handle assignment to self in operator=
: 又说为了making operator= exception-safe
: 要用copy and swap技术
: 所以要把operato=定义为
: Widget& Widget::operator=(Widget rhs) //pass by value
: {
: swap(rhs); //swap *this's data with the copy's
: return *this;

h***i
发帖数: 1970
12
听起来像是google.

【在 m***i 的大作中提到】
: My company C++ style guide: Neither operator overloading nor exception is
: allowed.

g**w
发帖数: 969
13
是啊,作者说的很清楚,
swap/exception safe基本型也是pass by reference实现,
pass by value是个trick,
他也很worry看起来不好。

【在 z****e 的大作中提到】
: 作者写的挺清楚的,打回去重读。
b******n
发帖数: 592
14
how does it work without exception? I used to use a lot macros in C, but it
is far from ideal. I'd like to learn.

【在 h***i 的大作中提到】
: 听起来像是google.
z****e
发帖数: 2024
15
that's the most general tone to show a trick in academic publication.
before others start to blame the author as zhuang B-ility, himself talk in a
conservertive tone about his zhuang Bility first.
As a result, he can zhuang B and defense all blames simultaneously.

【在 g**w 的大作中提到】
: 是啊,作者说的很清楚,
: swap/exception safe基本型也是pass by reference实现,
: pass by value是个trick,
: 他也很worry看起来不好。

c**b
发帖数: 2999
16
Widget rhs
Widget* rhs
Widget& rhs
可能书作者在炫耀他对这3个的区别很清楚.其实,写c++ 的那个人,就是为了炫耀他对内
存理解之深之透.

【在 S****z 的大作中提到】
: 首先说 operator= (const Widget& rhs) //pass by ref
: 用引用可以省copy constructor
: 但是在下面一章的handle assignment to self in operator=
: 又说为了making operator= exception-safe
: 要用copy and swap技术
: 所以要把operato=定义为
: Widget& Widget::operator=(Widget rhs) //pass by value
: {
: swap(rhs); //swap *this's data with the copy's
: return *this;

c**b
发帖数: 2999
17
还是选本好书看吧.每本c++书讲故事的方式都不一樣,看了一本,再去看另外一本,简直
就是找不到方向.

【在 S****z 的大作中提到】
: 原来这书作者是在BSO它自己的safe而其他书的不safe是吧
: 好吧,这次忍了,再往下读读看
: BTW:貌似还有本叫More Effective C++?既然它叫More Effective
: 那More的作者应该比这个没有More的更牛叉吧,我是不是直接读那本就行了
: 没必要在这本没有More的上浪费时间?

g**w
发帖数: 969
18
effective c++和c++ primer差不多
熟悉C, 看看两本里的任一本就可以了,
剩下的就是多写code

【在 c**b 的大作中提到】
: 还是选本好书看吧.每本c++书讲故事的方式都不一樣,看了一本,再去看另外一本,简直
: 就是找不到方向.

1 (共1页)
进入Programming版参与讨论
相关主题
Bjarne Stroustrup C++第四版电子版出来了C++,大家觉得最值得买最想买最不后悔买的书是哪本?
有人看了新版 1368页的 c++ programming language 吗VB, C++初学者清推荐书籍
大家要学习C++11啊, 我觉得C++11很多FEATURE,绝对不输JAVA.question about const reference
C++必备书籍推荐哪位大侠有如下书籍的电子版,或者下载地址,多谢
/usr/bin/ld: Undefined symbols:[合集] 请牛人解释为啥C++ has stronger typing than C//bow
问个C++的operator conversation function问题[合集] c++的dynamic_cast是如何实现的?
The untold truth about C++C++0x
Question on C++ Access Control (protected)读Bjarne Stroustrup写得The C++ programming language 是不是经常有不知所谓的感觉。
相关话题的讨论汇总
话题: widget话题: c++话题: rhs话题: effective话题: operator