Cplusplus 简明教程
C++ Overview
C++ 是一门静态类型、已编译、通用、区分大小写、自由格式的编程语言,它支持过程化、面向对象和泛型编程。
C++ is a statically typed, compiled, general-purpose, case-sensitive, free-form programming language that supports procedural, object-oriented, and generic programming.
C++ 被认为是一种 middle-level 语言,因为它包含高级和低级语言特性的组合。
C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features.
C 由比雅尼·斯特劳斯特鲁普于 1979 年在位于新泽西州默里山的贝尔实验室开发,作为对 C 语言的一个增强,最初命名为带类的 C,但后来在 1983 年更名为 C++。
C was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill, New Jersey, as an enhancement to the C language and originally named C with Classes but later it was renamed C in 1983.
C 是 C 的超集,因此几乎任何合法的 C 程序都是一个合法的 C 程序。
C is a superset of C, and that virtually any legal C program is a legal C program.
Note - 当类型检查在编译时执行(而不是在运行时执行)时,编程语言被认为使用静态类型。
Note − A programming language is said to use static typing when type checking is performed during compile-time as opposed to run-time.
Object-Oriented Programming
C++ 完全支持面向对象编程,包括面向对象开发的四大支柱:
C++ fully supports object-oriented programming, including the four pillars of object-oriented development −
-
Encapsulation
-
Data hiding
-
Inheritance
-
Polymorphism
Standard Libraries
标准 C++ 由三个重要部分组成:
Standard C++ consists of three important parts −
-
The core language giving all the building blocks including variables, data types and literals, etc.
-
The C++ Standard Library giving a rich set of functions manipulating files, strings, etc.
-
The Standard Template Library (STL) giving a rich set of methods manipulating data structures, etc.
The ANSI Standard
ANSI 标准旨在确保 C++ 可移植;您为 Microsoft 的编译器编写的代码在 Mac、UNIX、Windows 框或 Alpha 上使用编译器时将无错误地编译。
The ANSI standard is an attempt to ensure that C++ is portable; that code you write for Microsoft’s compiler will compile without errors, using a compiler on a Mac, UNIX, a Windows box, or an Alpha.
ANSI 标准已稳定了一段时间,所有主要的 C++ 编译器制造商都支持 ANSI 标准。
The ANSI standard has been stable for a while, and all the major C++ compiler manufacturers support the ANSI standard.
Learning C++
在学习 C++ 时最重要的就是要专注于概念。
The most important thing while learning C++ is to focus on concepts.
学习编程语言的目的是成为一名更好的程序员;即更有效地设计和实现新系统以及维护旧系统。
The purpose of learning a programming language is to become a better programmer; that is, to become more effective at designing and implementing new systems and at maintaining old ones.
C++ 支持各种编程风格。您可以在任何语言中以 Fortran、C、Smalltalk 等的风格编写。每种风格都可以在保持运行时和空间效率的同时有效地实现其目标。
C++ supports a variety of programming styles. You can write in the style of Fortran, C, Smalltalk, etc., in any language. Each style can achieve its aims effectively while maintaining runtime and space efficiency.
Use of C++
数以十万计的程序员在所有应用领域使用 C++。
C++ is used by hundreds of thousands of programmers in essentially every application domain.
C++ 用于编写设备驱动程序和其他软件,这些软件依赖于对硬件的直接操纵,并处于实时约束条件下。
C++ is being highly used to write device drivers and other software that rely on direct manipulation of hardware under realtime constraints.
C++ 广泛用于教学和研究,因为它足够干净,可以成功地教授基本概念。
C++ is widely used for teaching and research because it is clean enough for successful teaching of basic concepts.
任何使用 Apple Macintosh 或运行 Windows 的 PC 的人都间接地使用了 C,因为这些系统的用户界面都是用 C 编写的。
Anyone who has used either an Apple Macintosh or a PC running Windows has indirectly used C because the primary user interfaces of these systems are written in C.