Skip to Content
Effective Modern C++(中文版)
book

Effective Modern C++(中文版)

by Scott Meyers
April 2018
Intermediate to advanced
303 pages
4h 54m
Chinese
China Electric Power Press Ltd.
Content preview from Effective Modern C++(中文版)
转向现代
C++
85
auto vals1 = w.data();
//
调用
Widget::data
的左值重载版本
// vals1
采用复制构造完成初始化
auto vals2 = makeWidget().data();
//
调用
Widget::data
的右值重载版本
// vals2
采用移动构造完成初始化
这个结果固然让人欢欣鼓舞,但是我们不要让这个皆大欢喜的结果喧宾夺主,淡化了我
们这个条款的真正主题。这个主题是:无论何时,只要你在派生类中声明了一个函数,
并且该函数意在改写基类中的一个虚函数,请确保你给该函数加上
override
声明。
要点速记
为意在改写的函数添加
override
声明。
成员函数引用饰词使得对于左值和右值对象(
*this
)的处理能够区分开来。
条款
13
:优先选用
const_iterator
,而非
iterator
const_iterator
STL
中相当于指涉到
const
的指针的等价物。它们指涉到不可被
修改的值。只要有可能就应该使用
const
的标准实践表明,任何时候只要你需要一个
迭代器而其指涉到的内容没有修改必要,你就应该使用
const_iterator
这一点对于
C++98
C++11
都成立,但在
C++98
中,
const_iterator
得到的支持
不够全面。建立它们不容易,而建立好了以后使用它们的方式也受限。比如,假设你
想在
std::vector<int>
搜索第一次出现的
1983
(这一年,“
C++
”取代了“带类 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

C++程序设计:原理与实践(基础篇)(原书第2版)

C++程序设计:原理与实践(基础篇)(原书第2版)

本贾尼 斯特劳斯特鲁普
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普
Go语言编程

Go语言编程

威廉·肯尼迪

Publisher Resources

ISBN: 9787519817749