|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
Introducing C++ for Scientists, Engineers and Mathematicians
Written especially for scientists, engineers and mathematicians, this book has been extensively updated and revised to conform to 1998 ANSI/ISO C++ Standard and include all the recent developments in C++ such as:
- STL (Standard Template Library)
- Namespaces;
- Exception Handling
- Templates and Streams.
No knowledge of programming is assumed. This book is as much for the beginner in programming as it is for the newcomer to C++, although readers are expected to have some acquaintance with computers and text editors.
Plenty of relevant examples are included throughout the book, most of which are slanted towards numerical applications, and it is this bias that makes this book unique in its field and of particular interest to those who have to work with figures.
Content Level » Lower undergraduate Keywords » C++ - Programming Language Related subjects » Applications - Complexity - Software Engineering TABLE OF CONTENTS1 Introduction.- 1.1 Getting Started.- 1.2 Solving a Quadratic Equation.- 1.3 An Object-oriented Example.- 1.4 Why Object-oriented?.- 1.5 Summary.- 1.6 Exercises.- 2 The Lexical Basis of C++.- 2.1 Characters and Tokens.- 2.2 Comments and White Space.- 2.3 Identifiers.- 2.4 Keywords.- 2.5 Constants.- 2.5.1 Integer Constants.- 2.5.2 Boolean Constants.- 2.5.3 Floating Point Constants.- 2.5.4 Character Constants.- 2.5.5 String Constants.- 2.6 Operators.- 2.7 Programming Style.- 2.8 Summary.- 2.9 Exercises.- 3 Fundamental Types and Basic Operators.- 3.1 Integral Data Types.- 3.1.1 Type int.- 3.1.2 Integer Multiplication.- 3.1.3 Integer Division.- 3.1.4 Integer Modulus or Remainder Operator.- 3.1.5 Increment and Decrement Operators.- 3.1.6 Associativity and Precedence of Integer Operators.- 3.1.7 Long Integers.- 3.1.8 Short Integers.- 3.1.9 Unsigned Integers.- 3.1.10 Booleans.- 3.1.11 Character Types.- 3.2 Floating Point Data Types.- 3.2.1 Type double.- 3.2.2 Type float.- 3.2.3 Type long double.- 3.3 Changing Types.- 3.3.1 Type Promotion and Conversion.- 3.3.2 Casts.- 3.4 Some Basic Operations.- 3.4.1 The sizeof Operator.- 3.4.2 Initialization.- 3.4.3 Assignment Operators.- 3.5 const.- 3.6 typedef.- 3.7 Summary.- 3.8 Exercises.- 4 Control Structure.- 4.1 Relational Operators.- 4.2 Logical Operators.- 4.3 Equal and Not Equal Operators.- 4.4 Blocks and Scope.- 4.5 Branch Statements.- 4.5.1 if Statement.- 4.5.2 if else Statement.- 4.5.3 switch Statement.- 4.6 Iteration Statements.- 4.6.1 while Statement.- 4.6.2 for Statement.- 4.6.3 do Statement.- 4.7 break and continue Statements.- 4.8 goto Statement.- 4.9 Comma Operator.- 4.10 Null Statement.- 4.11 Conditional Expression Operator.- 4.12 Order of Evaluation of Operands.- 4.13 The Preprocessor.- 4.13.1 include Directive.- 4.13.2 define Directive.- 4.13.3 Conditional Compilation.- 4.14 Enumerations.- 4.15 Summary.- 4.16 Exercises.- 5 Functions.- 5.1Introducing Functions.- 5.1.1 Defining and Calling Functions.- 5.1.2 Return Type.- 5.1.3 Function Declarations.- 5.1.4 Functions Cannot Declare Functions.- 5.1.5 Unused Arguments.- 5.1.6 Default Arguments.- 5.1.7 Ignoring the Return Value.- 5.2 Recursion.- 5.3 Inline Functions.- 5.4 More on Scope Rules.- 5.5 Storage Class static.- 5.6 Overloading Function Names.- 5.6.1 Ambiguity Resolution.- 5.7 Function main0.- 5.8 Standard Library.- 5.9 Using Functions.- 5.9.1 A Benchmark.- 5.9.2 Root Finding by Bisection.- 5.10 Summary.- 5.11 Exercises.- 6 Pointers and Arrays.- 6.1 Memory, Addressing and Pointers.- 6.1.1 Address-of Operator.- 6.1.2 Dereferencing or Indirection Operator.- 6.1.3 Pointers.- 6.1.4 Pointers Do Not Declare Memory.- 6.1.5 Null Pointer.- 6.2 One-dimensional Arrays.- 6.2.1 Pointers and One-dimensional Arrays.- 6.3 Type void.- 6.4 Pointer Conversions.- 6.5 Multi-dimensional Arrays.- 6.5.1 Pointers and Multi-dimensional Arrays.- 6.6 Initializing Arrays.- 6.7 Size of Arrays.- 6.8 Arrays of Pointers.- 6.9 Using Pointers and Arrays.- 6.9.1 Fitting Data to a Straight Line.- 6.9.2 Ragged Arrays.- 6.10 Summary.- 6.11 Exercises.- 7 Further Pointer Techniques.- 7.1 Strings.- 7.2 Pointers as Function Arguments.- 7.3 Passing Arrays as Function Arguments.- 7.3.1 One-dimensional Arrays.- 7.3.2 Multi-dimensional Arrays.- 7.4 Arguments to main().- 7.5 Pointers to Functions.- 7.6 Dynamic Memory Management.- 7.6.1 Allocating Memory.- 7.6.2 Deallocating Memory.- 7.7 Pass by Reference and Reference Variables.- 7.7.1 Reference Arguments.- 7.7.2 Reference Return Values.- 7.7.3 Reference Variables.- 7.8 Using Pointers, Arrays and Strings.- 7.8.1 Matrix Addition.- 7.8.2 An Alphabetic Sort.- 7.9 Summary.- 7.10 Exercises.- 8 Classes.- 8.1 Declaring Classes.- 8.2 Class Access Specifiers.- 8.3 Accessing Members.- 8.4 Assigning Objects.- 8.5 Functions and Classes.- 8.6 Data Hiding.- 8.7 Returning an Object.- 8.8 Reference Arguments.- 8.9 Pointers to Members.- 8.10 Pointer-to-Member Operators.- 8.11 Scope and Data Protection.- 8.12 Static Members.- 8.12.1 Static Data Members.- 8.12.2 Static Member Functions.- 8.13 Constructor Functions.- 8.14 Accessing const Class Objects.- 8.15 Friend Functions.- 8.16 Program Structure and Style.- 8.16.1 Separate Compilation.- 8.16.2 Header Files.- 8.17 Using Classes.- 8.18 Summary.- 8.19 Exercises.- 9 Operator Overloading.- 9.1 Introducing Overloaded Operators.- 9.1.1 Overloading the Assignment Operator.- 9.1.2 The this Pointer.- 9.1.3 Overloading the Addition Operator.- 9.1.4 Overloading the Unary Minus Operator.- 9.2 User-defined Conversions.- 9.2.1 Conversion by Constructors.- 9.2.2 Conversion Functions.- 9.2.3 Implicit Conversions.- 9.3 Operator Function Calls.- 9.3.1 Binary Operators.- 9.3.2 Prefix Unary Operators.- 9.3.3 Postfix Unary Operators.- 9.4 Some Special Binary Operators.- 9.4.1 Overloading the Subscripting Operator.- 9.4.2 Overloading the Function Call Operator.- 9.5 Defining Overloaded Operators.- 9.6 Using Overloaded Operators.- 9.6.1 Complex Arithmetic.- 9.6.2 Strings.- 9.7 Summary.- 9.8 Exercises.- 10 Constructors and Destructors.- 10.1 More on Constructor Functions.- 10.1.1 Dynamic Memory Management.- 10.1.2 Assignment and Initialization.- 10.1.3 Member Objects with Constructors.- 10.2 Destructor Functions.- 10.3 Using Constructors and Destructors.- 10.3.1 Singly Linked Lists.- 10.3.2 Doubly Linked Lists.- 10.4 Summary.- 10.5 Exercises.- 11 Bitwise Operations.- 11.1 Bitwise Operators.- 11.1.1 Bitwise Complement.- 11.1.2 Bitwise AND.- 11.1.3 Bitwise Exclusive OR.- 11.1.4 Bitwise Inclusive OR.- 11.1.5 Shift Operators.- 11.1.6 Bitwise Assignment Operators.- 11.2 Bit-fields.- 11.3 Unions.- 11.4 Using Bitwise Operators.- 11.4.1 A Bit Array Class.- 11.4.2 The Sieve of Eratosthenes.- 11.4.3 Bit Representation of Integral Types.- 11.4.4 Bit Representation of Floating Point Types.- 11.5 Summary.- 11.6 Exercises.- 12 Single Inheritance.- 12.1 Derived Classes.- 12.2 virtual Functions.- 12.3 Abstract Classes.- 12.4 Class Hierarchies.- 12.5 Constructors and Destructors.- 12.6 Member Access and Inheritance.- 12.6.1 Access Specifiers.- 12.6.2 Friendship and Derivation.- 12.7 Using Single Inheritance.- 12.7.1 A Bounds Checked Array Class.- 12.7.2 A Menu Class.- 12.8 Summary.- 12.9 Exercises.- 13 Multiple Inheritance.- 13.1 Derived Classes.- 13.2 Virtual Base Classes.- 13.3 Constructors and Destructors.- 13.4 Member Access Ambiguities.- 13.5 Using Multiple Inheritance.- 13.6 Summary.- 13.7 Exercises.- 14 Namespaces.- 14.1 Name Clashes.- 14.2 Creating a Namespace.- 14.3 Accessing Namespace Members.- 14.4 More on Creating Namespaces.- 14.5 Namespace Aliases.- 14.6 The using Directive.- 14.7 The using Declaration.- 14.8 The Standard Library.- 14.9 Unnamed Namespaces.- 14.10 Using Namespaces.- 14.11 Summary.- 14.12 Exercises.- 15 Exception Handling.- 15.1 Errors.- 15.2 Introducing throw, try and catch.- 15.3 Throwing a Fundamental Type.- 15.4 Extracting Information from a catch.- 15.5 Catching Everything.- 15.6 Derived Error Classes.- 15.7 Exception Specifications.- 15.8 Uncaught Exceptions.- 15.9 Dynamic Memory Allocation.- 15.10 Using Exception Handling.- 15.11 Summary.- 15.12 Exercises.- 16 Templates.- 16.1 Function Templates.- 16.2 Class Templates.- 16.3 Static Members.- 16.4 Class Templates and Functions.- 16.5 Function Template Arguments.- 16.6 Template Parameters.- 16.7 Templates and Friends.- 16.8 Specialized Templates.- 16.9 Member Function Specialization.- 16.10 Program Structure.- 16.11 Using Templates.- 16.12 Summary.- 16.13 Exercises.- 17 Standard Library.- 17.1 Introduction.- 17.2 Library Categories.- 17.2.1 Language Support.- 17.2.2 Diagnostics.- 17.2.3 General Utilities.- 17.2.4 Strings.- 17.2.5 Localization.- 17.2.6 Containers.- 17.2.7 Iterators.- 17.2.8 Algorithms.- 17.2.9 Numerics.- 17.3 Using the Standard Library.- 17.3.1 Complex Arithmetic.- 17.3.2 Boolean Arrays.- 17.4 Summary.- 17.5 Exercises.- 18 Input and Output.- 18.1 Introduction.- 18.2 Input and Output Classes.- 18.3 Output.- 18.3.1 Unformatted Output.- 18.4 Input.- 18.4.1 Unformatted Input.- 18.5 Flags, Manipulators and Formatting.- 18.6 File Input and Output.- 18.7 Assigning Streams.- 18.8 Stream Condition.- 18.9 User-defined Types.- 18.10 Using Input and Output.- 18.11 Summary.- 18.12 Exercises.- Appendix—A The ASCII Character Codes.- Appendix—B Operators.- Appendix—C Differences between C and C++.
|
|