- ホーム
- > 洋書
- > 英文書
- > Computer / Languages
Full Description
A Ready Reference for C++C++ for the Impatient offers both the quickest way for busy programmers to learn the latest features of the C++ language and a handy resource for quickly finding answers to specific language questions. Designed to give you the most accurate and up-to-date information you require fast and to the point, this book is also an essential guide to the new C++11 standard, including advanced uses of the C++ standard library. Features include * Concise descriptions of nearly every function, object, and operator in the C++ core language and standard library, with clear, well-chosen examples for each of them* Information provided "at a glance" through syntax displays, tables, and summaries of important functions* Content organized for quick look-up of needed information * Simple explanations of advanced concepts, using helpful illustrations* Complete program examples that are both useful and intriguing, including puzzles, games, and challenging exercisesC++11 features, all covered in the book, include:* Lambdas* rvalue references* Regular-expression library* Randomization library* Hash-table containers* Smart pointersC++ for the Impatient is an ideal resource for anyone who needs to come up to speed quickly on C++11. Whether or not it's your first C++ book, it will be one you come back to often for reliable answers.
Contents
Preface xixAcknowledgments xxviiAbout the Author xxixChapter 1: C++ Fundamentals 11.1 Elements of a C++ Program 11.2 Dealing with "Flashing Console" 41.3 Working with Microsoft Visual Studio 51.4 Doing More with C++ 61.5 Adding Simple Variable Declarations 71.6 Introduction to C++ Control Structures 101.6.1 Making Decisions with "if" 111.6.2 Looping with "while" 131.7 General Structure of a C++ Program 141.8 More about Namespaces 151.9 Some Comments about Comments 171.9.1 C++ Comments (Line Comments) 171.9.2 C-Language-Style Comments 171.10 Sample App: Adding Machine 19Exercises 201.11 Sample App: Calculating Phi 20Exercises 23Chapter 2: Data 252.1 Declaring Simple Variables 252.2 Primitive Data Types 272.3 Symbolic Names ("Symbols") 302.4 Numeric Literals 312.5 Mixing Numeric Types 332.5.1 Integer versus Floating Point 342.5.2 bool versus Integer Types 342.5.3 Signed versus Unsigned Integers 352.6 String and Character Literals 392.6.1 Single-Quoted Characters 392.6.2 Double-Quoted Strings 402.6.3 Special Characters (Escape Sequences) 412.6.4 Wide-Character Strings 452.6.5 Raw String Literals (C++11) 462.7 Data Declarations: The Complete Syntax 462.8 Enumerated Types 502.9 Special Declarations (typedef, auto, decltype) 522.9.1 The typedef Keyword 522.9.2 The auto and decltype Keywords (C++11) 532.10 Sample App: Type Promotion 54Exercises 55Chapter 3: Operators 573.1 Precedence, Associativity, and Lvalues 573.2 Concise Summary of Operators 593.3 Operators in Detail 623.4 The Great Controversy: Postfix or Prefix? 773.5 Bitwise Operators in Detail 783.6 Cast Operators 82Exercises 90Chapter 4: Control Structures 914.1 Concise Summary of C++ Statements 914.2 Null Statements (;) and Expression Statements 934.3 Compound Statements 944.4 if and if-else Statements 964.5 while and do-while Statements 984.6 for Statements 994.7 Range-based for Statements (C++11) 1014.8 switch Statements 1034.9 Jump Statements (break, continue, goto) 1044.10 Exception Handling (try, catch) 1064.11 Sample App: Guess-the-Number Game 111Exercises 1134.12 Sample App: Computer Guesses the Number 113Exercises 115Chapter 5: Functions 1175.1 Overview of Traditional (Named) Functions 1175.2 Local and Global Variables 1225.3 Complete Function Declaration Syntax 1245.4 Function Overloading 1265.5 Arguments with Default Values 1285.6 Variable-Length Argument Lists 1295.7 Lambda, or Anonymous, Functions (C++11) 1315.8 constexpr Functions (C++11) 1415.9 Sample App: Odds at Dice 142Exercises 145Chapter 6: Pointers, Arrays, and References 1476.1 References 1476.2 Arrays 1526.3 Pointers 1596.4 Complex Declarations Involving Pointers 1756.5 Passing and Returning Function Pointers 1786.6 Smart Pointers (C++11) 1806.7 Sample App: Sieve of Eratosthenes 186Exercises 188Chapter 7: Classes and Objects 1897.1 Overview: Structures, Unions, and Classes 1897.2 Basic Class Declaration Syntax 1917.3 Constructors 2057.4 Destructors 2167.5 The Hidden "this" Pointer 2177.6 Operator Functions (Op Overloading) 2187.7 Deriving Classes (Subclassing) 2297.8 Bit Fields 2407.9 Unions 2427.10 Sample App: Packed Boolean 245Exercises 248Chapter 8: Preprocessor Directives 2498.1 General Syntax of Preprocessor Directives 2498.2 Summary of Preprocessor Directives 2508.3 Using Directives to Solve Specific Problems 2548.3.1 Creating Meaningful Symbols with #define 2548.4 Preprocessor Operators 2598.5 Predefined Macros 2608.6 Creating Project Header Files 263Chapter 9: Creating and Using Templates 2659.1 Templates: Syntax and Overview 2659.2 Function Templates 2679.3 Class Templates 2729.4 Class Templates with Member Functions 2769.4.1 Class Templates with Inline Member Functions 2769.4.2 Class Templates with Separate Function Definitions 2769.5 Using Integer Template Parameters 2789.6 Template Specialization 2799.7 Variadic Templates (C++11) 2819.8 Sample App: Type Promotion, v 2 288Exercises 289Chapter 10: C-String Library Functions 29110.1 Overview of the C-String Format 29110.2 Input and Output with C-Strings 29310.3 C-String Functions 29410.4 String Tokenizing with strtok 30010.5 Individual-Character Functions 30110.6 Memory-Block Functions (memcpy, and so on) 30410.7 Wide-Character Functions (wstrcpy, and so on) 306Chapter 11: C I/O Library Functions 30911.1 Overview of C Library I/O 30911.2 Console I/O Functions 31011.3 Print/Scan Formats 31311.4 Input and Output to Strings 32111.5 File I/O 321Chapter 12: Math, Time, and Other Library Functions 33312.1 Trigonometric Functions 33312.2 Other Math Functions 33612.3 The C Date and Time Library 33912.4 String-to-Number Conversions 34712.5 Memory-Allocation Functions 34812.6 Standard C Randomization Functions 35012.7 Searching and Sorting Functions 35112.8 Other Standard C Library Functions 35512.9 Sample App: Idiot Savant 358Exercises 359Chapter 13: C++ I/O Stream Classes 36113.1 The Basics of C++ I/O Streams 36113.2 Reading a Line of Input with getline 36413.3 The C++ Stream-Class Hierarchy 36613.4 Stream Objects: Manipulators and Flags 36813.5 Stream Member Functions (General Purpose) 37913.6 File Stream Operations 38513.7 Reading and Writing String Streams 39513.8 Overloading Shift Operators for Your Classes 39813.9 Sample App: Text File Reader 400Exercises 401Chapter 14: The C++ STL String Class 40314.1 Overview of the String Class 40314.2 String Class Constructors 40514.3 String Class Operators 40614.4 Concise Summary of Member Functions 41014.5 Member Functions in Detail 41014.6 String Class Iterators 42414.7 Wide-Character String Class (basic_string) 430Chapter 15: Introduction to STL (vector, deque) 43115.1 A Tour of the Container Templates 43115.2 Introduction to Iterators 43315.3 The vector Template 43415.4 The deque Template 44715.5 The bitset Template 45815.5.1 bitset Constructors 45915.6 Sample App: Alpha File Organizer 461Exercises 463Chapter 16: STL Sequence Containers (List) 46516.1 Sorting Elements (Strict Weak Ordering) 46516.2 The list Template 46616.2.3 Concise Summary of list Functions 47116.2.4 List Member Functions in Detail 47216.3 The stack Template 48116.4 The queue Template 48416.5 The priority_queue Template 48716.6 Sample App: Find the Median 491Exercises 493Chapter 17: STL Associated Containers (map, set) 49517.1 The pair Template 49517.2 The map Template 49717.3 The set Template 51817.4 The multimap Template 52917.5 The multiset Template 53217.6 Unordered Containers (C++11) 53417.7 Sample App: Guess-the-Word Game 543Exercises 545Chapter 18: STL Algorithms 54718.1 STL Algorithms: General Concepts 54718.2 Using Lambda Functions (C++11) 55018.3 Algorithms and Iterators 55118.4 Insert Iterators 55318.5 Sample App: Finding the Median 55518.6 Concise Summaries of Algorithms 55618.7 Detailed Descriptions of Algorithms 564Chapter 19: C++11 Randomization Library 59919.1 Issues in Randomization 59919.2 A Better Randomization Scheme 60119.3 Common Engines 60419.4 Common Distributions 60519.5 Operations on Engines 60819.6 Operations on Distributions 60919.7 Sample App: Dice Game 610Exercises 612Chapter 20: C++11 Regular-Expression Library 61320.1 Overview of C++11 Regular Expressions 61320.2 Dealing with Escape Sequences ( ) 61620.3 Constructing a RegEx String 61820.4 Matching and Searching Functions 62420.5 "Find All," or Iterative, Searches 62620.6 Replacing Text 62820.7 String Tokenizing 63020.8 Catching RegEx Exceptions 63120.9 Sample App: RPN Calculator 632Exercises 635Appendix A: A Painless Introduction to Rvalue References (C++11) 637A.1 The Trouble with Copying 637A.2 Move Semantics: C++11 to the Rescue! 640A.3 Rvalue Refs in a User's String Class 642A.4 Verifying Runtime-Performance Improvement 645A.5 Rvalues and Contained Objects 646A.6 References Reconsidered: Rvalues and Lvalues 646Appendix B: Summary of New Features in C++11 649B.1 Improvements in Object Construction 649B.2 Other Core-Language Enhancements 650B.3 Other New Keywords 651B.4 Extensions to the Standard Library 652Appendix C: ASCII Codes 655Index 659