Skip to Content
C++语言导学(原书第2版)
book

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

by 本贾尼 斯特劳斯特鲁普
August 2021
Intermediate to advanced
450 pages
5h 35m
Chinese
Pearson
Content preview from C++语言导学(原书第2版)

2.1 引言

用基本类型(参见1.4节)、const修饰符(参见1.6节)和声明运算符(参见1.7节)构造出来的类型,称为内置类型(built-in type)。C++的内置类型及其操作非常丰富,不过有意设计得更偏底层。这些内置类型能直接、高效地反映传统计算机硬件的能力,但是没有为程序员提供便于编写高级应用程序的高层设施。取而代之,C++在内置类型和操作的基础上增加了一套精致的抽象机制(abstraction mechanism),程序员可用它来构造所需的高层设施。

C++抽象机制的目的主要是令程序员能够设计并实现他们自己的数据类型,这些类型具有恰如其分的表示和操作,程序员可以简单优雅地使用它们。利用C++的抽象机制从其他类型构造出来的类型被称为用户自定义类型(user-defined type),即类(class)和枚举(enumeration)。用户自定义类型可以基于内置类型构造,也可基于其他用户自定义类型构造。本书的大部分内容都在着重介绍用户自定义类型的设计、实现和使用。用户自定义类型通常优于内置类型,因为其更易用、更不易出错,而且通常与直接使用内置类型实现相同功能一样高效,甚至更快。

本章的剩余部分将呈现类型定义和使用相关的最简单同时也是最基础的语言设施。第4~7章对抽象机制及其支持的编程风格进行了更加详细的介绍。第8~15章给出标准库的概述,因为标准库主要是由用户自定义类型组成的,所以这些章节也提供了很好的示例,展示了用第1~7章介绍的语言设施和编程技术能做什么。

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

软件开发实践:项目驱动式的Java开发指南

软件开发实践:项目驱动式的Java开发指南

Raoul-Gabriel Urma, Richard Warburton
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey
Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu

Publisher Resources

ISBN: 9787111633280