Practical C++ Programming

Programming Style Guidelines

Af Steve Oualline
Detaljer 2. Udgave O'Reilly Media, Incorporated
ISBN 9780596004194
Sprog Engelsk
Vælg mellem
Pris 421,00 kr.
Paperback

Ikke på lager

Ikke på lager. Bestil nu og få den leveret om ca. 12 hverdage

C++ is a powerful, highly flexible, and adaptable programming language that allows software engineers to organize and process information quickly and effectively. But this high-level language is relatively difficult to master, even if you already know the C programming language.The 2nd edition of Practical C++ Programming is a complete introduction to the C++ language for programmers who are learning C++. Reflecting the latest changes to the C++ standard, this 2nd edition takes a useful down-to-earth approach, placing a strong emphasis on how to design clean, elegant code. In short, to-the-point chapters, all aspects of programming are covered including style, software engineering, programming design, object-oriented design, and debugging. It also covers common mistakes and how to find (and avoid) them. End of chapter exercises help you ensure you've mastered the material. Practical C++ Programming thoroughly covers:
  • C++ Syntax
  • Coding standards and style
  • Creation and use of object classes
  • Templates
  • Debugging and optimization
  • Use of the C++ preprocessor
  • File input/output
Steve Oualline's clear, easy-going writing style and hands-on approach to learning make Practical C++ Programming a nearly painless way to master this complex but powerful programming language.

Preface; Scope of This Handbook; How This Book Is Organized; How to Read This Book If You Already Know C; Font Conventions; How to Contact Us; Acknowledgments for the First Edition; Acknowledgments for the Second Edition;
Part I: The Basics;
Chapter 1: What Is C++?;
1.1 A Brief History of C++;
1.2 C++ Organization;
1.3 How to Learn C++;
Chapter 2: The Basics of Program Writing;
2.1 Programs from Conception to Execution;
2.2 Creating a Real Program;
2.3 Getting Help in Unix;
2.4 Getting Help in an IDE;
2.5 Programming Exercises;
Chapter 3: Style;
3.1 Comments;
3.2 C++ Code;
3.3 Naming Style;
3.4 Coding Religion;
3.5 Indentation and Code Format;
3.6 Clarity;
3.7 Simplicity;
3.8 Consistency and Organization;
3.9 Further Reading;
3.10 Summary;
Chapter 4: Basic Declarations and Expressions;
4.1 Basic Program Structure;
4.2 Simple Expressions;
4.3 The std::cout Output Object;
4.4 Variables and Storage;
4.5 Variable Declarations;
4.6 Integers;
4.7 Assignment Statements;
4.8 Floating-Point Numbers;
4.9 Floating-Point Divide Versus Integer Divide;
4.10 Characters;
4.11 Wide Characters;
4.12 Boolean Type;
4.13 Programming Exercises;
4.14 Answers to
Chapter Questions;
Chapter 5: Arrays, Qualifiers, and Reading Numbers;
5.1 Arrays;
5.2 Strings;
5.3 Reading Data;
5.4 Initializing Variables;
5.5 Multidimensional Arrays;
5.6 C-Style Strings;
5.7 Types of Integers;
5.8 Types of Floats;
5.9 Constant and Reference Declarations;
5.10 Qualifiers;
5.11 Hexadecimal and Octal Constants;
5.12 Operators for Performing Shortcuts;
5.13 Side Effects;
5.14 Programming Exercises;
5.15 Answers to
Chapter Questions;
Chapter 6: Decision and Control Statements;
6.1 if Statement;
6.2 else Statement;
6.3 How Not to Use std::strcmp;
6.4 Looping Statements;
6.5 while Statement;
6.6 break Statement;
6.7 continue Statement;
6.8 The Assignment Anywhere Side Effect;
6.9 Programming Exercises;
6.10 Answers to
Chapter Questions;
Chapter 7: The Programming Process;
7.1 Setting Up Your Work Area;
7.2 The Specification;
7.3 Code Design;
7.4 The Prototype;
7.5 The Makefile;
7.6 Testing;
7.7 Debugging;
7.8 Maintenance;
7.9 Revisions;
7.10 Electronic Archaeology;
7.11 Mark Up the Program;
7.12 Use the Debugger;
7.13 Use the Text Editor as a Browser;
7.14 Add Comments;
7.15 Programming Exercises;
Part II: Simple Programming;
Chapter 8: More Control Statements;
8.1 for Statement;
8.2 switch Statement;
8.3 switch, break, and continue;
8.4 Programming Exercises;
8.5 Answers to
Chapter Questions;
Chapter 9: Variable Scope and Functions;
9.1 Scope and Storage Class;
9.2 Namespaces;
9.3 Functions;
9.4 Summary of Parameter Types;
9.5 Recursion;
9.6 Structured Programming Basics;
9.7 Real-World Programming;
9.8 Programming Exercises;
9.9 Answers to
Chapter Questions;
Chapter 10: The C++ Preprocessor;
10.1 #define Statement;
10.2 Conditional Compilation;
10.3 #include Files;
10.4 Parameterized Macros;
10.5 Advanced Features;
10.6 Summary;
10.7 Programming Exercises;
10.8 Answers to
Chapter Questions;
Chapter 11: Bit Operations;
11.1 Bit Operators;
11.2 The AND Operator (&);
11.3 Bitwise OR ( );
11.4 The Bitwise Exclusive OR (^);
11.5 The Ones Complement Operator (NOT) (~);
11.6 The Left and Right Shift Operators (>);
11.7 Setting, Clearing, and Testing Bits;
11.8 Bitmapped Graphics;
11.9 Programming Exercises;
11.10 Answers to
Chapter Questions;
Part III: Advanced Types and Classes;
Chapter 12: Advanced Types;
12.1 Structures;
12.2 Unions;
12.3 typedef;
12.4 enum Type;
12.5 Bit Members or Packed Structures;
12.6 Arrays of Structures;
12.7 Programming Exercises;
12.8 Answers to
Chapter Questions;
Chapter 13: Simple Classes;
13.1 Stacks;
13.2 Improved Stack;
13.3 Using a Class;
13.4 Introduction to Constructors and Destructors;
13.5 Automatically Generated Member Functions;
13.6 Shortcuts;
13.7 Style;
13.8 Structures Versus Classes;
13.9 Programming Exercises;
Chapter 14: More on Classes;
14.1 Friends;
14.2 Constant Functions;
14.3 Constant Members;
14.4 Static Member Variables;
14.5 Static Member Functions;
14.6 The Meaning of static;
14.7 Programming Exercises;
Chapter 15: Simple Pointers;
15.1 const Pointers;
15.2 Pointers and Printing;
15.3 Pointers and Arrays;
15.4 The reinterpret_cast;
15.5 Pointers and Structures;
15.6 Command-Line Arguments;
15.7 Programming Exercises;
15.8 Answers to
Chapter Questions;
Part IV: Advanced Programming Concepts;
Chapter 16: File Input/Output;
16.1 C++ File I/O;
16.2 Conversion Routines;
16.3 Binary and ASCII Files;
16.4 The End-of-Line Puzzle;
16.5 Binary I/O;
16.6 Buffering Problems;
16.7 Unbuffered I/O;
16.8 Designing File Formats;
16.9 C-Style I/O Routines;
16.10 C-Style Conversion Routines;
16.11 C-Style Binary I/O;
16.12 C- Versus C++- Style I/O;
16.13 Programming Exercises;
16.14 Answers to
Chapter Questions;
Chapter 17: Debugging and Optimization;
17.1 Code Reviews;
17.2 Serial Debugging;
17.3 Going Through the Output;
17.4 Interactive Debuggers;
17.5 Debugging a Binary Search;
17.6 Interactive Debugging Tips and Tricks;
17.7 Runtime Errors;
17.8 Optimization;
17.9 How to Optimize;
17.10 Case Study: Inline Functions Versus Normal Functions;
17.11 Case Study: Optimizing a Color-Rendering Algorithm;
17.12 Programming Exercises;
17.13 Answers to
Chapter Questions;
Chapter 18: Operator Overloading;
18.1 Creating a Simple Fixed-Point Class;
18.2 Operator Functions;
18.3 Operator Member Functions;
18.4 Warts;
18.5 Full Definition of the Fixed-Point Class;
18.6 Programming Exercises;
18.7 Answers to
Chapter Questions;
Chapter 19: Floating Point;
19.1 Floating-Point Format;
19.2 Floating Addition/Subtraction;
19.3 Multiplication and Division;
19.4 Overflow and Underflow;
19.5 Roundoff Error;
19.6 Accuracy;
19.7 Minimizing Roundoff Error;
19.8 Determining Accuracy;
19.9 Precision and Speed;
19.10 Power Series;
19.11 Programming Exercises;
Chapter 20: Advanced Pointers;
20.1 Pointers, Structures, and Classes;
20.2 delete Operator;
20.3 Linked Lists;
20.4 Ordered Linked Lists;
20.5 Doubly Linked Lists;
20.6 Trees;
20.7 Printing a Tree;
20.8 The Rest of the Program;
20.9 Data Structures for a Chess Program;
20.10 Programming Exercises;
20.11 Answers to
Chapter Questions;
Chapter 21: Advanced Classes;
21.1 Derived Classes;
21.2 Virtual Functions;
21.3 Virtual Classes;
21.4 Function Hiding in Derived Classes;
21.5 Constructors and Destructors in Derived Classes;
21.6 The dynamic_cast Operator;
21.7 Summary;
21.8 Programming Exercises;
21.9 Answers to
Chapter Questions;
Part V: Other Language Features;
Chapter 22: Exceptions;
22.1 Adding Exceptions to the Stack Class;
22.2 Exceptions Versus assert;
22.3 Programming Exercises;
Chapter 23: Modular Programming;
23.1 Modules;
23.2 Public and Private;
23.3 The extern Storage Class;
23.4 Headers;
23.5 The Body of the Module;
23.6 A Program to Use Infinite Arrays;
23.7 The Makefile for Multiple Files;
23.8 Using the Infinite Array;
23.9 Dividing a Task into Modules;
23.10 Module Design Guidelines;
23.11 Programming Exercises;
Chapter 24: Templates;
24.1 What Is a Template?;
24.2 Templates: The Hard Way;
24.3 Templates: The C++ Way;
24.4 Function Specialization;
24.5 Class Templates;
24.6 Class Specialization;
24.7 Implementation Details;
24.8 Advanced Features;
24.9 Summary;
24.10 Programming Exercises;
Chapter 25: Standard Template Library;
25.1 STL Basics;
25.2 Class List--A Set of Students;
25.3 Creating a Waiting List with the STL List;
25.4 Storing Grades in a STL Map;
25.5 Putting It All Together;
25.6 Practical Considerations When Using the STL;
25.7 Getting More Information;
25.8 Exercises;
Chapter 26: Program Design;
26.1 Design Goals;
26.2 Design Factors;
26.3 Design Principles;
26.4 Coding;
26.5 Objects;
26.6 Real-World Design Techniques;
26.7 Conclusion;
Chapter 27: Putting It All Together;
27.1 Requirements;
27.2 Code Design;
27.3 Coding;
27.4 Functional Description;
27.5 Testing;
27.6 Revisions;
27.7 A Final Warning;
27.8 Program Files;
27.9 Programming Exercises;
Chapter 28: From C to C++;
28.1 K&R-Style Functions;
28.2 struct;
28.3 malloc and free;
28.4 Turning Structures into Classes;
28.5 setjmp and longjmp;
28.6 Mixing C and C++ Code;
28.7 Summary;
28.8 Programming Exercise;
Chapter 29: C++''s Dustier Corners;
29.1 do/while;
29.2 goto;
29.3 The ?: Construct;
29.4 The Comma Operator;
29.5 Overloading the ( ) Operator;
29.6 Pointers to Members;
29.7 The asm Statement;
29.8 The mutable Qualifier;
29.9 Run Time Type Identification;
29.10 Trigraphs;
29.11 Answers to
Chapter Questions;
Chapter 30: Programming Adages;
30.1 General;
30.2 Design;
30.3 Declarations;
30.4 switch Statement;
30.5 Preprocessor;
30.6 Style;
30.7 Compiling;
30.8 The Ten Commandments for C++ Programmers;
30.9 Final Note;
30.10 Answers to
Chapter Questions;
Part VI: Appendixes; Appendix A: ASCII Table; Appendix B: Ranges; Appendix C: Operator Precedence Rules; C.1 Standard Rules; C.2 Practical Subset of the Operator Precedence Rules; Appendix D: Computing Sine Using a Power Series; Appendix E: Resources; E.1 Compilers; E.2 Standard Template Library; E.3 Standards; E.4 Programming Tools;Colophon;