没有合适的资源?快使用搜索试试~ 我知道了~
首页掌握现代C++编程入门指南
掌握现代C++编程入门指南
需积分: 9 8 下载量 12 浏览量
更新于2024-07-18
收藏 4.58MB PDF 举报
"《初级C++编程》是一本旨在引领读者步入强大且广泛应用的C++编程世界的入门书籍。作者理查德·格里姆斯所著,由Packt Publishing出版,版权日期为2017年。本书专注于现代C++语言的实践应用,不仅教会读者如何利用标准库进行编程,还强调了面向对象编程的核心概念以及内存管理的安全与高效使用。 本书的目的是让初学者能够掌握基础的编程技巧,包括数据结构、核心语言特性等,这些都是构建任何程序的基础。C++以其强大的功能和灵活性深受开发者喜爱,本书将帮助读者理解其背后的原理,以便于在实际项目中得心应手。通过丰富的代码示例和深入浅出的讲解,作者引导读者逐步提升对C++的理解和熟练程度。 然而,需要明确的是,虽然本书力求提供准确的信息,但出于印刷和更新的限制,可能会存在一定的误差或过时内容。作者和出版社不对由于书中信息导致的直接或间接损失承担责任。此外,尽管书中尽可能标注了商标信息,但读者需自行确认其准确性,因为 Packt Publishing 无法对此做出完全的保证。 《初级C++编程》适合那些希望进入C++编程领域的初学者,无论是对软件开发感兴趣的学生还是希望升级现有技能的专业人士。通过阅读这本书,读者将建立起坚实的C++编程基础,为进一步深入学习和开发项目打下坚实的基础。" 这是一本全面且实用的C++教程,对于想要开启C++编程之旅的人来说,是不可或缺的参考资料。
资源详情
资源推荐
[ viii ]
Unordered containers 369
Special purpose containers
369
Using iterators
371
Input and output iterators 373
Stream iterators 375
Using iterators with the C Standard Library 377
Algorithms
378
Iteration of items
378
Getting information
381
Comparing containers
382
Changing Items
382
Finding Items
385
Sorting items
386
Using the numeric libraries
389
Compile time arithmetic
389
Complex numbers
391
Using the Standard Library
393
Summary
400
Chapter 9: Using Strings
401
Using the string class as a container
401
Getting information about a string
402
Altering strings
403
Searching strings
405
Internationalization
407
Using facets
408
Strings and numbers
412
Converting strings to numbers
412
Converting numbers to strings
412
Using stream classes
413
Outputting floating point numbers
413
Outputting integers
417
Outputting time and money
417
Converting numbers to strings using streams
419
Reading numbers from strings using streams
421
Using regular expressions
424
Defining regular expressions
424
Standard Library classes
426
Matching expressions 428
Using iterators 430
Replacing strings 433
[ ix ]
Using strings
433
Creating the project
434
Processing header subitems
439
Summary
443
Chapter 10: Diagnostics and Debugging
444
Preparing your code
444
Invariants and conditions
444
Conditional compilation
446
Using pragmas
447
Adding informational messages
449
Compiler switches for debugging
452
Pre-processor symbols
453
Producing diagnostic messages
456
Trace messages with the C runtime 459
Tracing messages with Windows 461
Using asserts
463
Application termination
465
Error values
466
Obtaining message descriptions
467
Using the Message Compiler
469
C++ exceptions
470
Exception specifications
471
C++ exception syntax
471
Standard exception classes
474
Catching exceptions by type
475
Function try blocks
478
System errors
480
Nested exceptions
481
Structured Exception Handling
483
Compiler exception switches
486
Mixing C++ and SEH exception handling
487
Writing exception-safe classes
489
Summary
491
Index
492
Preface
C++ has been used for 30 years, and during that time, many new languages have come and
gone, but C++ has endured. The big question behind this book is: Why? Why use C++? The
answer lies in the ten chapters you see in front of you but, as a spoiler, it is the flexibility
and power of the language and the rich, broad Standard Library.
C++ has always been a powerful language, giving you direct access to memory while
providing high-level features such as the ability to create new types—classes—and to
override operators to suit your needs. However, the more modern C++ standards added to
this, generic programming through templates, and functional programming through
function objects and lambda expressions. You can use as much or as little of these features
as you want; you can write event-driven code with abstract interface pointers, or C-like
procedural code.
In this book, we will take you through the features of the 2011 standard of C++ and the
Standard Library provided with the language. The text explains how to use these features
with short code snippets, and each chapter has a worked example illustrating the concepts.
At the end of this book, you will be aware of all the features of the language and what can
be possible with the C++ Standard Library. You will start this book as a beginner, and finish
it informed and equipped to use C++.
What this book covers
Chapter 1, Starting with C++, explains the files used to write C++ applications, file
dependencies, and the basics of C++ project management.
Chapter 2, Understanding Language Features, covers C++ statements and expressions,
constants, variables, operators, and how to control execution flow in applications.
Chapter 3, Exploring C++ Types, describes C++ built-in types, aggregated types, type aliases,
initializer lists, and conversion between types.
Chapter 4, Working with Memory, Arrays, and Pointers, covers how memory is allocated and
used in C++ applications, how to use built-in arrays, the role of C++ references, and how to
use C++ pointers to access memory.
Chapter 5, Using Functions, explains how to define functions, how to pass parameters-by-
reference and by-value using a variable number of parameters, creating and using pointers
to functions, and defining template functions and overloaded operators.
Preface
[ 2 ]
Chapter 6, Classes, describes how to define new types through classes and the various
special functions used in a class, how to instantiate a class as an object and how to destroy
them, and how to access objects through pointers and how to write template classes.
Chapter 7, Introduction to Object-Orientated Programming, explains inheritance and
composition, and how this affects using pointers and references to objects and the access
levels of class members and how they affect inherited members. This chapter also explains
polymorphism through virtual methods, and inheritance programming through abstract
classes.
Chapter 8, Using Standard Library Containers, covers all the C++ Standard Library container
classes and how to use them with iterators and the standard algorithms so that you can
manipulate the data in containers.
Chapter 9, Using Strings, describes the features of the standard C++ string class, converting
between numeric data and strings, internationalizing strings, and using regular expressions
to search and manipulate strings.
Chapter 10, Diagnostics and Debugging, explains how to prepare your code to provide
diagnostics and to enable it to be debugged, how applications are terminated, abruptly or
gracefully, and how to use C++ exceptions.
What you need for this book
This book covers the C++11 standard, and the associated C++ Standard Library. For the vast
majority of this book, any C++11 compliant compiler is suitable. This includes compilers
from Intel, IBM, Sun, Apple, and Microsoft, as well as the open source GCC compiler.
This book uses Visual C++ 2017 Community Edition because it is a fully featured compiler
and environment, and it is provided as a free download. This is a personal choice of the
author, but it should not restrict readers who prefer using other compilers. Some of the
sections of the last chapter on Diagnostics and Debugging describe Microsoft-specific features,
but these sections are clearly marked.
Who this book is for
This book is intended for experienced programmers who are new to C++. The reader is
expected to understand what high-level languages are for and basic concepts such as
modularizing code and controlling execution flow.
Preface
[ 3 ]
Conventions
In this book, you will find a number of text styles that distinguish between different kinds
of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions,
pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can
include other contexts through the use of the include directive."
A block of code is set as follows:
class point
{
public:
int x, y;
};
When we wish to draw your attention to a particular part of a code block, the relevant lines
or items are set in bold:
class point
{
public:
int x, y;
point(int _x, int _y) : x(_x), y(_y) {}
};
Any command-line input or output is written as follows:
C:\> cl /EHsc test.cpp
New terms and important words are shown in bold. Words that you see on the screen, for
example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button
moves you to the next screen."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
剩余515页未读,继续阅读
i_fisher
- 粉丝: 2
- 资源: 42
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 新型矿用本安直流稳压电源设计:双重保护电路
- 煤矿掘进工作面安全因素研究:结构方程模型
- 利用同位素位移探测原子内部新型力
- 钻锚机钻臂动力学仿真分析与优化
- 钻孔成像技术在巷道松动圈检测与支护设计中的应用
- 极化与非极化ep碰撞中J/ψ的Sivers与cos2φ效应:理论分析与COMPASS验证
- 新疆矿区1200m深孔钻探关键技术与实践
- 建筑行业事故预防:综合动态事故致因理论的应用
- 北斗卫星监测系统在电网塔形实时监控中的应用
- 煤层气羽状水平井数值模拟:交替隐式算法的应用
- 开放字符串T对偶与双空间坐标变换
- 煤矿瓦斯抽采半径测定新方法——瓦斯储量法
- 大倾角大采高工作面设备稳定与安全控制关键技术
- 超标违规背景下的热波动影响分析
- 中国煤矿选煤设计进展与挑战:历史、现状与未来发展
- 反演技术与RBF神经网络在移动机器人控制中的应用
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功