Bestselling Programming Tutorial and Reference Completely Rewritten for the New C++11 Standard Fully updated and recast for the newly released C++11 standard, this authoritative and comprehensive introduction to C++ will help you to learn the language fast, and to use it in modern, highly effective ways. Highlighting today’s best practices, the authors show how to use both the core language and its standard library to write efficient, readable, and powerful code. C++ Primer, Fifth Edition, introduces the C++ standard library from the outset, drawing on its common functions and facilities to help you write useful programs without first having to master every language detail. The book’s many examples have been revised to use the new language features and demonstrate how to make the best use of them. This book is a proven tutorial for those new to C++, an authoritative discussion of core C++ concepts and techniques, and a valuable resource for experienced programmers, especially those eager to see C++11 enhancements illuminated. Start Fast and Achieve More Learn how to use the new C++11 language features and the standard library to build robust programs quickly, and get comfortable with high-level programming Learn through examples that illuminate today’s best coding styles and program design techniques Understand the “rationale behind the rules”: why C++11 works as it does Use the extensive crossreferences to help you connect related concepts and insights Benefit from up-to-date learning aids and exercises that emphasize key points, help you to avoid pitfalls, promote good practices, and reinforce what you’ve learned Access the source code for the extended examples from informit.com/title/0321714113 C++ Primer, Fifth Edition, features an enhanced, layflat binding, which allows the book to stay open more easily when placed on a flat surface. This special binding method—notable by a small space inside the spine—also increases durability. This classic and definitive text on the C++ language has been extensively revised and expanded. In its third edition, it is based on the final draft specification of ANSI/ISO Standard. Be forewarned, this is a primer in name only; there is nothing simplistic in its presentation or in its breadth and scope. Knowledge of C is NOT assumed, but knowledge of object-oriented programming and a modern language will make this text more understandable. As the authors point out, "This book is intended as a first book on C++; it is not intended as a first book on programming!" Contents 8 Preface 24 Chapter 1 Getting Started 30 1.1 Writing a Simple C++ Program 31 1.1.1 Compiling and Executing Our Program 32 1.2 A First Look at Input/Output 34 1.3 A Word about Comments 38 1.4 Flow of Control 40 1.4.1 The while Statement 40 1.4.2 The for Statement 42 1.4.3 Reading an Unknown Number of Inputs 43 1.4.4 The if Statement 46 1.5 Introducing Classes 48 1.5.1 The Sales_itemClass 49 1.5.2 A First Look at Member Functions 52 1.6 The Bookstore Program 53 Chapter Summary 55 Defined Terms 55 Part I: The Basics 58 Chapter 2 Variables and Basic Types 60 2.1 Primitive Built-in Types 61 2.2 Variables 70 2.3 Compound Types 79 2.4 Const Qualifier 88 2.5 Dealing with Types 96 2.6 Defining Our Own Data Structures 101 Chapter Summary 107 Defined Terms 107 Chapter 3 Strings, Vectors, and Arrays 110 3.1 Namespace using Declarations 111 3.2 Library string Type 113 3.3 Library vector Type 125 3.4 Introducing Iterators 135 3.5 Arrays 142 3.6 Multidimensional Arrays 154 Chapter Summary 160 Defined Terms 160 Chapter 4 Expressions 162 4.1 Fundamentals 163 4.2 Arithmetic Operators 168 4.3 Logical and Relational Operators 170 4.4 Assignment Operators 173 4.5 Increment and Decrement Operators 176 4.6 The Member Access Operators 179 4.7 The Conditional Operator 180 4.8 The Bitwise Operators 181 4.9 The sizeof Operator 185 4.10 Comma Operator 186 4.11 Type Conversions 188 4.12 Operator Precedence Table 195 Chapter Summary 197 Defined Terms 197 Chapter 5 Statements 200 5.1 Simple Statements 201 5.2 Statement Scope 203 5.3 Conditional Statements 203 5.4 Iterative Statements 212 5.5 Jump Statements 219 5.6 Try Blocks and Exception Handling 222 Chapter Summary 228 Defined Terms 228 Chapter 6 Functions 230 6.1 Function Basics 231 6.2 Argument Passing 237 6.3 Return Types and the return Statement 251 6.4 Overloaded Functions 259 6.5 Features for Specialized Uses 265 6.6 Function Matching 271 6.7 Pointers to Functions 276 Chapter Summary 280 Defined Terms 280 Chapter 7 Classes 282 7.1 Defining Abstract Data Types 283 7.2 Access Control and Encapsulation 297 7.3 Additional Class Features 300 7.4 Class Scope 311 7.5 Constructors Revisited 317 7.6 Static Class Members 329 Chapter Summary 334 Defined Terms 334 Part II: The C++ Library 336 Chapter 8 The IO Library 338 8.1 The IO Classes 339 8.2 File Input and Output 345 8.3 string Streams 350 Chapter Summary 353 Defined Terms 353 Chapter 9 Sequential Containers 354 9.1 Overview of the Sequential Containers 355 9.2 Container Library Overview 357 9.3 Sequential Container Operations 370 9.4 How a vector Grows 384 9.5 Additional string Operations 389 9.6 Container Adaptors 397 Chapter Summary 401 Defined Terms 401 Chapter 10 Generic Algorithms 404 10.1 Overview 405 10.2 A First Look at the Algorithms 407 10.3 Customizing Operations 414 10.4 Revisiting Iterators 430 10.5 Structure of Generic Algorithms 439 10.6 Container-Specific Algorithms 444 Chapter Summary 446 Defined Terms 446 Chapter 11 Associative Containers 448 11.1 Using an Associative Container 449 11.2 Overview of the Associative Containers 452 11.3 Operations on Associative Containers 457 11.4 The Unordered Containers 472 Chapter Summary 476 Defined Terms 476 Chapter 12 Dynamic Memory 478 12.1 Dynamic Memory and Smart Pointers 479 12.2 Dynamic Arrays 505 12.3 Using the Library: A Text-Query Program 513 Chapter Summary 520 Defined Terms 520 Part III: Tools for Class Authors 522 Chapter 13 Copy Control 524 13.1 Copy, Assign, and Destroy 525 13.2 Copy Control and Resource Management 539 13.3 Swap 545 13.4 A Copy-Control Example 548 13.5 Classes That Manage Dynamic Memory 553 13.6 Moving Objects 560 Chapter Summary 578 Defined Terms 578 Chapter 14 Overloaded Operations and Conversions 580 14.1 Basic Concepts 581 14.2 Input and Output Operators 585 14.3 Arithmetic and Relational Operators 589 14.4 Assignment Operators 592 14.5 Subscript Operator 593 14.6 Increment and Decrement Operators 595 14.7 Member Access Operators 598 14.8 Function-Call Operator 600 14.9 Overloading, Conversions, and Operators 608 Chapter Summary 619 Defined Terms 619 Chapter 15 Object-Oriented Programming 620 15.1 OOP: An Overview 621 15.2 Defining Base and Derived Classes 623 15.3 Virtual Functions 632 15.4 Abstract Base Classes 637 15.5 Access Control and Inheritance 640 15.6 Class Scope under Inheritance 646 15.7 Constructors and Copy Control 651 15.8 Containers and Inheritance 659 15.9 Text Queries Revisited 663 Chapter Summary 678 Defined Terms 678 Chapter 16 Templates and Generic Programming 680 16.1 Defining a Template 681 16.2 Template Argument Deduction 707 16.3 Overloading and Templates 723 16.4 Variadic Templates 728 16.5 Template Specializations 735 Chapter Summary 742 Defined Terms 742 Part IV: Advanced Topics 744 Chapter 17 Specialized Library Facilities 746 17.1 The tuple Type 747 17.2 The bitset Type 752 17.3 Regular Expressions 757 17.4 Random Numbers 774 17.5 The IO Library Revisited 781 Chapter Summary 798 Defined Terms 798 Chapter 18 Tools for Large Programs 800 18.1 Exception Handling 801 18.2 Namespaces 814 18.3 Multiple and Virtual Inheritance 831 Chapter Summary 845 Defined Terms 845 Chapter 19 Specialized Tools and Techniques 848 19.1 Controlling Memory Allocation 849 19.2 Run-Time Type Identification 854 19.3 Enumerations 861 19.4 Pointer to Class Member 864 19.5 Nested Classes 872 19.6 Union: A Space-Saving Class 876 19.7 Local Classes 881 19.8 Inherently Nonportable Features 883 Chapter Summary 891 Defined Terms 891 Appendix A: The Library 894 A.1 Library Names and Headers 895 A.2 A Brief Tour of the Algorithms 899 A.2.1 Algorithms to Find an Object 900 A.2.2 Other Read-Only Algorithms 901 A.2.3 Binary Search Algorithms 902 A.2.4 Algorithms That Write Container Elements 902 A.2.5 Partitioning and Sorting Algorithms 904 A.2.6 General Reordering Operations 906 A.2.7 Permutation Algorithms 908 A.2.8 Set Algorithms for Sorted Sequences 909 A.2.9 Minimum and Maximum Values 909 A.2.10 Numeric Algorithms 910 A.3 Random Numbers 911 A.3.1 Random Number Distributions 912 A.3.2 Random Number Engines 913 Index 916 A 919 B 922 C 924 D 930 E 933 F 935 G 938 H 938 I 939 K 942 L 942 M 944 N 946 O 948 P 951 Q 954 R 954 S 957 T 962 U 964 V 965 W 966 X 967 Z 967 Bestselling Programming Tutorial and Reference Completely Rewritten for the New C 11 Standard Fully updated and recast for the newly released C 11 standard, this authoritative and comprehensive introduction to C will help you to learn the language fast, and to use it in modern, highly effective ways. Highlighting today’s best practices, the authors show how to use both the core language and its standard library to write efficient, readable, and powerful code. C Primer, Fifth Edition, introduces the C standard library from the outset, drawing on its common functions and facilities to help you write useful programs without first having to master every language detail. The book’s many examples have been revised to use the new language features and demonstrate how to make the best use of them. This book is a proven tutorial for those new to C , an authoritative discussion of core C concepts and techniques, and a valuable resource for experienced programmers, especially those eager to see C 11 enhancements illuminated. Start Fast and Achieve More Learn how to use the new C 11 language features and the standard library to build robust programs quickly, and get comfortable with high-level programming Learn through examples that illuminate today’s best coding styles and program design techniques Understand the “rationale behind the rules”: why C 11 works as it does Use the extensive crossreferences to help you connect related concepts and insights Benefit from up-to-date learning aids and exercises that emphasize key points, help you to avoid pitfalls, promote good practices, and reinforce what you’ve learned Access the source code for the extended examples from informit.com/title/0321714113 C Primer, Fifth Edition, features an enhanced, layflat binding, which allows the book to stay open more easily when placed on a flat surface. This special binding method—notable by a small space inside the spine—also increases durability. Книга Язык программирования C++. Базовый курс (5-е издание) - лучшее руководство по программированию и справочник по языку, полностью пересмотренное и обновленное под стандарт C++11! Книга Язык программирования C++. Базовый курс - новое издание популярного и исчерпывающего бестселлера по языку программирования C++, которое было полностью пересмотрено и обновлено под стандарт C++11. Оно поможет вам быстро изучить язык и использовать его весьма эффективными и передовыми способами. В соответствии с самыми передовыми и современными методиками изложения материала авторы демонстрируют использование базового языка и его стандартной библиотеки для разработки эффективного, читабельного и мощного кода The third edition of the C++ Primer combines Stanley Lippman's practical experience with Josee Lajoie's inside knowledge of the ANSI/ISO Standard C++. This tutorial is rewritten to describe the features and programming usage of Standard C++. Especially useful for developers new to C++ are the many real-world programming examples that illustrate the design of generic and object-oriented programs, the use of templates, and other aspects of program design using Standard C++. In addition, the C++ Primer provides usage and efficiency guidelines where appropriate.