内容简介
Part Ⅰ C++ programming basics
1 Introduction
1.1 Objective
1.2 Presentation
1.3 Why C++
1.4 C++ standards
1.5 Summary
1.6 How to use this text
1.7 Additional study aids
1.8 Additional and alternative software packages
2 Installing and running the Dev-C++ programming environment
2.1 Compiling and running a first program
2.2 Using the Dev-C++ debugger
2.3 Installing DISLIN and gsl
2.4 A first graphics program
2.5 The help system
2.6 Linux alternatives
2.7 Assignment
3 Introduction to computer and software architecture
3.1 Computational methods
3.2 Hardware architecture
3.3 Software architecture
3.4 The operating system and application software
3.5 Assignments
4 Fundamental concepts
4.1 Overview of program structure
4.2 Tokens,names,and keywords
4.3 Expressions and statements
4.4 Constants,variables,and identifiers
4.5 Declarations,definitions,and scope
4.6 rvalues and lvalues
4.7 Block structure
4.8 The const keyword
4.9 Operators-precedence and associativity
4.10 Formatting conventions
4.11 Comments
4.12 Assignments
5 Writing a first program
5.1 The main() function
5.2 Namespaces
5.3 #include Statements
5.4 Input and output streams
5.5 File streams
5.6 Constant and variable types
5.7 Casts
5.8 Operators
5.9 Control flow
5.10 Functions
5.11 Arrays and typedefs
5.12 A first look at scientific software development
5.13 Program errors
5.14 Numerical errors with floating-point types
5.15 Assignments
6 An introduction to object-oriented analysis
6.1 Procedural versus object-oriented programming
6.2 Problem definition
6.3 Requirements specification
6.4 UML diagrams
6.5 Use case diagram
6.6 Classes and objects
6.7 Object discovery
6.8 Sequence and collaboration diagrams
6.9 Aggregation and association
6.10 Inheritance
6.11 Object-oriented programming approaches
6.12 Assignments
7 C++ object-oriented programming syntax
7.1 Class declaration
7.2 Class definition and member functions
7.3 Object creation and polymorphism
7.4 Information hiding
7.5 Constructors
7.6 Wrappering legacy code
7.7 Inheritance
7.8 The'protected'keyword
7.9 Assignments
8 Control logic and iteration
8.1 The bool and enum types
8.2 Logical operators
8.3 if statements and implicit blocks
8.4 else,else if,conditional and switch statements
8.5 The exit()function
8.6 Conditional compilation
8.7 The for statement
8.8 while and do...while statements
8.9 The break and continue statements
8.10 Assignments
9 Basic function properties
9.1 Principles of function operation
9.2 Function declarations and prototypes
9.3 Overloading and argument conversion
9.4 Built-in functions and header files
9.5 Program libraries
9.6 Function preconditions and postconditions-the assert statement
9.7 Multiple return statements
9.8 Functions and global variables
9.9 Use of const in functions
9.10 Default parameters
9.11 Inline functions
9.12 Modular programming
9.13 Recursive functions
9.14 Assignments
10 Arrays and matrices
10.1 Data structures and arrays
10.2 Array definition and initialization
10.3 Array manipulation and memory access
10.4 Arrays as function parameters
10.5 Returning arrays and object arrays
10.6 const arrays
10.7 Matrices
10.8 Matrix storage and loop order
10.9 Matrices as function arguments
10.10 Assignments
11 Input and output streams
11.1 The iostream class and stream manipulators
11.2 File streams
11.3 The string class and string streams
11.4 The toString()class member
11.5 The printf function
11.6 Assignments
Part Ⅱ Numerical analysis
12 Numerical error analysis-derivatives
12.1 The derivative operator
12.2 Error dependence
12.3 Graphical error analysis
12.4 Analytic error analysis-higher-order methods
12.5 Extrapolation
12.6 The derivative calculator class
12.7 Assignments
13 Integration
13.1 Discretization procedures
13.2 Implementation
13.3 Discretization error
13.4 Assignments
14 Root-finding procedures
14.1 Bisection method
14.2 Newton's method
14.3 Assignments
15 Differential equations
15.1 Euler's method
15.2 Error analysis
15.3 The spring class
15.4 Assignments
16 Linear algebra
16.1 Linear equation solvers
16.2 Errors and condition numbers
16.3 Eigenvalues and iterative eigenvalue solvers
16.4 Assignments
Part Ⅲ Advanced object-oriented programming
17 References
17.1 Basic properties
17.2 References as function arguments
17.3 Reference member variables
17.4 const reference variables
17.5 Reference return values
17.6 Assignments
18 Pointers and dynamic memory allocation
18.1 Introduction to pointers
18.2 Initializing pointer variables
18.3 The address-of and dereferencing operators
18.4 Uninitialized pointer errors
18.5 NULL and void pointers
18.6 Dangling pointers
18.7 Pointers in function blocks
18.8 The const keyword and pointers
18.9 Pointer arithmetic
18.10 Pointers and arrays
18.11 Pointer comparisons
18.12 Pointers to pointers and matrices
18.13 String manipulation
18.14 Static and dynamic memory allocation
18.15 Memory leaks and dangling pointers
18.16 Dynamic memory allocation within functions
18.17 Dynamically allocated matrices
18.18 Dynamically allocated matrices as function arguments and parameters
18.19 Pointer data structures and linked lists
18.20 Assignments
19 Advanced memory management
19.1 The this pointer
19.2 The friend keyword
19.3 Operators
19.4 Destructors
19.5 Assignment operators
19.6 Copy constructors
19.7 Assignments
20 The static keyword,multiple and virtual inheritance,templates,and the STL library
20.1 Static variables
20.2 Static class members
20.3 Pointer to class members
20.4 Multiple inheritance
20.5 Virtual functions
20.6 Heterogeneous object collections and runtime type identification
20.7 Abstract base classes and interfaces
20.8 Virtual inheritance
20.9 User-defined conversions
20.10 Function templates
20.11 Templates and classes
20.12 The complex class
20.13 The standard template library
20.14 Structures and unions
20.15 Bit fields and operators
20.16 Assignments
21 Program optimization in C++
21.1 Compiling
21.2 Critical code segments
21.3 Virtual functions
21.4 Function pointers and functors
21.5 Aliasing
21.6 High-performance template libraries
21.7 Assignments
Part Ⅳ Scientific programming examples
22 Monte Carlo methods
22.1 Monte Carlo integration
22.2 Monte Carlo evaluation of distribution functions
22.3 Importance sampling
22.4 The metropolis algorithm
22.5 Multicanonical methods
22.6 Assignments
23 Parabolic partial differential equation solvers
23.1 Partial differential equations in scientific applications
23.2 Direct solution methods
23.3 The Crank-Nicholson method
23.4 Assignments
Appendix A Overview of MATLAB
Appendix B The Borland C++ Compiler
B.1 Borland C++ installation
B.2 Compiling and running a first program
B.3 Installing the optional program editor
B.4 Using the Borland turbo debugger
B.5 Installing DISLIN
B.6 A first graphics program
B.7 The help system
Appendix C The Linux/Windows Command-Line C++ Compiler and Profiler
Appendix D Calling FORTRAN programs from C++
Appendix E C++ coding standard
E.1 Program design language
E.2 Comments
E.3 Layout
E.4 Continuation lines
E.5 Constants and literals
E.6 Variables and definitions
E.7 Functions
E.8 Operators
E.9 Classes
E.10 Typedefs
E.11 Macros
E.12 Templates
E.13 Control structures
References and further reading
Index