وبلاگ بلیان

انتقال از C به C++: بررسی مشکلات برنامه‌نویسی، چرایی وجود آن‌ها و چگونگی حل آن‌ها توسط C++

Moving from C to C++: Discussing Programming Problems, Why They Exist, and How C++ Solves Them

معرفی کتاب «انتقال از C به C++: بررسی مشکلات برنامه‌نویسی، چرایی وجود آن‌ها و چگونگی حل آن‌ها توسط C++» (با عنوان لاتین Moving from C to C++: Discussing Programming Problems, Why They Exist, and How C++ Solves Them) نوشتهٔ Arunesh K Goyal، منتشرشده توسط نشر Apress : Distributed to the Book trade worldwide by Springer Science+Business Media New York در سال 2013. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.

The author says it best, "I hope to move you, a little at a time, from understanding C to the point where C++ becomes your mindset." This remarkable book is designed to streamline the process of learning C++ in a way that discusses programming problems, why they exist, and the approach C++ has taken to solve such problems. "You can't just look at C++ as a collection of features; some of the features make no sense in isolation. You can only use the sum of the parts if you are thinking about design, not simply coding. To understand C++, you must understand the problems with C and with programming in general. This book discusses programming problems, why they are problems, and the approach C++ has taken to solve such problems. Thus, the set of features that I explain in each chapter will be based on the way that I see a particular type of problem being solved in C++." Tailor made to treat difficult concepts in a simple and practical way, the book focuses on building a customizable model for the reader which helps in deducing the solution of any puzzle that one might encounter. The book presents the material one simple step at a time, so the reader can easily digest each concept before moving on. It uses examples that are as simple and as short as possible. This book does not to use any particular vendor's version of C++ because, for learning the language, the details of a particular implementation are not as important as the language itself. All code in the book was run against the Visual Studio (Microsoft) C++ compiler and Apple's Xcode C++ compiler to ensure accuracy. What you'll learn To look at C++ as a way to express and tackle more and more complex concepts Understand that C++ is not just a collection of features in isolation To think about design, not simply coding To understand the problems with C and with programming, in general and how they are addressed in C++ Build up a solid foundation so that you can understand the issues well enough to move on Who this book is for C programmers in the process of adopting C++. Readers should at minimum have a reading level comfort with C. " Contents at a Glance Contents About the Author Acknowledgments Introduction Chapter 1: Introduction to Objects The Progress of Abstraction An Object Has An Interface The Hidden Implementation Reusing the Implementation Inheritance: Reusing the Interface Is-a vs. is-like-a Relationships Interchangeable Objects with Polymorphism Creating and Destroying Objects Exception Handling: Dealing with Errors Analysis and Design Phase 0: Make a Plan The Mission Statement Phase 1: What are we making? Phase 2: How will we build it? Five Stages of Object Design Guidelines for Object Development Phase 3: Build the Core Phase 4: Iterate the Use Cases Phase 5: Evolution Plans Pay Off Extreme Programming Write Tests First Pair Programming Why C++ Succeeds A Better C You’re Already on the Learning Curve Efficiency Systems Are Easier to Express and Understand Maximal Leverage with Libraries Source-Code Reuse with Templates Error Handling Programming in the Large Strategies for Transition Guidelines Training Low-Risk Project Model from Success Use Existing Class Libraries Don’t Rewrite Existing Code in C++ Management Obstacles Startup Costs Performance Issues Common Design Errors Review Session Chapter 2: Making and Using Objects The Process of Language Translation Interpreters Compilers The Compilation Process Static Type Checking Tools for Separate Compilation Declarations vs. Definitions Function Declaration Syntax Function Definitions Variable Declaration Syntax Including Headers Standard C++ include Format Linking Using Libraries How the Linker Searches a Library Secret Additions Using Plain C Libraries Your First C++ Program Using the iostream Class Namespaces Fundamentals of Program Structure "Hello, World!" Running the Compiler More About iostream Character Array Concatenation Reading Input Calling Other Programs Introducing Strings Reading and Writing Files Introducing Vector Review Session Chapter 3: The C in C++ Creating Functions Function Return Values Using the C Function Library Creating Your Own Libraries with the Librarian Controlling Execution True and False Using if-else Using while Using do-while Using for The break and continue Keywords Using switch Using and Misusing goto Recursion Introduction to Operators Precedence Auto-Increment and Auto-Decrement Introduction to Data Types Basic Built-in Types Using bool, true, and false Using Specifiers Introduction to Pointers Modifying the Outside Object Introduction to C++ References Pointers and References as Modifiers Understanding Scoping Defining Variables on the Fly Specifying Storage Allocation Global Variables Local Variables Register Variables The static Keyword The extern Keyword Linkage Constants Constant Values The volatile Qualifier Operators and Their Use Assignment Mathematical Operators Introduction to Preprocessor Macros Relational Operators Logical Operators Bitwise Operators Shift Operators Unary Operators The Ternary Operator The Comma Operator Common Pitfalls when Using Operators Casting Operators C++ Explicit Casts Using static_cast Using const_cast Using reinterpret_cast sizeof—An Operator by Itself The asm Keyword Explicit Operators Composite Type Creation Aliasing Names with typedef Combining Variables with struct Pointers and structs Clarifying Programs with enum Type Checking for Enumerations Saving Memory with union Using Arrays Pointers and Arrays Exploring Floating-Point Format Pointer Arithmetic Debugging Hints Debugging Flags Preprocessor Debugging Flags Runtime Debugging Flags Turning Variables and Expressions into Strings The C assert() Macro Function Addresses Defining a Function Pointer Complicated Declarations and Definitions Using a Function Pointer Arrays of Pointers to Functions make: Managing Separate Compilation Make Activities Macros Suffix Rules Default Targets An Example makefile The I/O System Review Session Chapter 4: Data Abstraction A Tiny C -like Library Dynamic Storage Allocation Bad Guesses What’s wrong? The Basic Object What’s an object? Abstract Data Typing Object Details Header File Etiquette Importance of Header Files The Multiple-Declaration Problem The Preprocessor Directives:#define, #ifdef, #endif A Standard for Header Files Namespaces in Headers Using Headers in Projects Nested Structures Global Scope Resolution Review Session Chapter 5: Hiding the Implementation Setting Limits C++ Access Control Another Access Specifier: protected Friends Nested Friends Is it pure? Object Layout The Class Modifying Stash to Use Access Control Modifying Stack to Use Access Control Handle Classes Hiding the Implementation Reducing Recompilation Review Session Chapter 6: Initialization and Cleanup Guaranteed Initialization with the Constructor Guaranteed Cleanup with the Destructor Elimination of the Definition Block for loops Storage Allocation Stash with Constructors and Destructors Stack with Constructors and Destructors Aggregate Initialization Default Constructors Review Session Chapter 7: Function Overloading and Default Arguments More Name Decoration Overloading on Return Values Type-Safe Linkage Overloading Example Unions Default Arguments Placeholder Arguments Choosing Overloading vs. Default Arguments Review Session Chapter 8: Constants Value Substitution const in Header Files Safety consts Aggregates Differences with C Pointers Pointer to const const Pointer Formatting Assignment and Type Checking Character Array Literals Function Arguments and Return Values Passing by const Value Returning by const Value Temporaries Passing and Returning Addresses Standard Argument Passing Classes const in Classes The Constructor Initializer List “Constructors” for Built-in Types Compile-Time Constants in Classes The “enum hack” in Old Code const Objects and Member Functions Mutable: Bitwise vs. Logical const ROMability The volatile Keyword Review Session Chapter 9: Inline Functions Preprocessor Pitfalls Macros and Access Inline Functions Inlines Inside Classes Access Functions Accessors and Mutators Stash and Stack with Inlines Inlines and the Compiler Limitations Forward References Hidden Activities in Constructors and Destructors Reducing Clutter More Preprocessor Features Token Pasting Improved Error Checking Review Session Chapter 10: Name Control Static Elements from C Static Variables Inside Functions Static Class Objects Inside Functions Static Object Destructors Controlling Linkage Confusion Other Storage Class Specifiers Namespaces Creating a namespace Unnamed Namespaces Friends Using a Namespace Scope Resolution The using Directive The using Declaration The Use of Namespaces Static Members in C++ Defining Storage for Static Data Members static Array Initialization Nested and Local Classes static Member Functions Static Initialization Dependency Solving the Problem Technique One Technique Two Alternate Linkage Specifications Review Session Chapter 11: References and the Copy Constructor Pointers in C++ References in C++ References in Functions const References Pointer References Argument-Passing Guidelines The Copy-Constructor Passing and Returning by Value Passing and Returning Large Objects Function-Call Stack Frame Reentrancy Bit-Copy vs. Initialization Copy-Construction Temporary Objects Default Copy-Constructor Alternatives to Copy-Construction Preventing Pass-by-value Functions That Modify Outside Objects Pointers-to-Members Functions An Example Review Session Chapter 12: Operator Overloading Warning and Reassurance Syntax Overloadable Operators Unary Operators Increment and Decrement Binary Operators Arguments and Return Values Return by Value as a const The Return Optimization Unusual Operators Operator Comma Operator-> A Nested Iterator Operator->* Operators You Can’t Overload Non-Member Operators Basic Guidelines Overloading Assignment Behavior of operator= Pointers in Classes Reference Counting Automatic operator= Creation Automatic Type Conversion Constructor Conversion Preventing Constructor Conversion Operator Conversion Reflexivity Type Conversion Example Pitfalls in Automatic Type Conversion Hidden Activities Chapter 13: Dynamic Object Creation Object Creation C’s Approach to the Heap Operator new Operator delete Memory Manager Overhead Early Examples Redesigned delete void* is Probably a Bug Cleanup Responsibility with Pointers Stash for Pointers A Test Using new and delete for Arrays Making a Pointer More Like an Array Running Out of Storage Overloading new and delete Overloading Global new and delete Overloading new and delete for a Class Overloading new and delete for Arrays Constructor Calls Placing new and delete Review Session Chapter 14: Inheritance and Composition Composition Syntax Inheritance Syntax The Constructor Initializer List Member Object Initialization Built-in Types in the Initializer List Combining Composition and Inheritance Automatic Destructor Calls Order of Constructor and Destructor Calls Name Hiding Functions That Don’t Automatically Inherit Inheritance and Static Member Functions Choosing Composition vs. Inheritance Subtyping private Inheritance Publicizing Privately Inherited Members The protected Keyword protected Inheritance Operator Overloading and Inheritance Multiple Inheritance Incremental Development Upcasting Why “upcasting?” Upcasting and the copy-constructor Composition vs. Inheritance (Revisited) Pointer and Reference Upcasting A Crisis Review Session Chapter 15: Polymorphism and Virtual Functions Evolution of C++ Programmers Upcasting The Problem Function Call Binding Using Virtual Functions Extensibility How C++ Implements Late Binding Storing Type Information Picturing Virtual Functions Under the Hood Installing the Vpointer Objects Are Different Why virtual functions? Abstract Base Classes and Pure Virtual Functions Pure Virtual Definitions Inheritance and the VTABLE Object Slicing Overloading and Overriding Variant Return Type Virtual Functions and Constructors Order of Constructor Calls Behavior of Virtual Functions Inside Constructors Destructors and Virtual Destructors Pure Virtual Destructors Virtuals in Destructors Creating an Object-Based Hierarchy Operator Overloading Downcasting Review Session Chapter 16: Introduction to Templates Containers The Need for Containers Overview of Templates The C Solution The Smalltalk Solution The Template Solution Template Syntax Non-Inline Function Definitions Header Files IntStack as a Template Constants in Templates Stack and Stash as Templates Templatized pointer Stash Turning Ownership On and Off Holding Objects by Value Introducing Iterators Stack with Iterators PStash with Iterators Why iterators? Function Templates Review Session Chapter 17: Exception Handling Traditional Error Handling Throwing an Exception Catching an Exception The try Block Exception Handlers Termination and Resumption Exception Matching Catching Any Exception Rethrowing an Exception Uncaught Exceptions The terminate( ) Function The set_terminate( ) Function Cleaning Up Resource Management Making Everything an Object Using auto_ptr Function–Level try Blocks Standard Exceptions Exception Specifications The unexpected() Function The set_unexpected() Function Better Exception Specifications? Exception Specifications and Inheritance When Not to Use Exception Specifications Exception Safety Programming with Exceptions When to Avoid Exceptions Not for Asynchronous Events Not for Benign Error Conditions Not for Flow–of–Control You’re Not Forced To Use Exceptions New Exceptions, Old Code Typical Uses of Exceptions When to Use Exception Specifications Start with Standard Exceptions Nest Your Own Exceptions Use Exception Hierarchies Multiple Inheritance (MI) Catch By Reference, Not By Value Throw Exceptions in Constructors Don’t Cause Exceptions in Destructors Avoid Naked Pointers Overhead Review Session Chapter 18: Strings in Depth What’s in a string? Creating and Initializing C++ Strings Operating on Strings Appending, Inserting, and Concatenating Strings Replacing String Characters Simple Character Replacement Using the STL replace() Algorithm Concatenation Using Nonmember Overloaded Operators Searching in Strings Finding in Reverse Finding First/Last of a Set of Characters Removing Characters from Strings Comparing Strings Strings and Character Traits A String Application Review Session Chapter 19: iostreams Why iostreams? iostreams to the Rescue Inserters and Extractors Common Usage Line–Oriented Input Overloaded Versions of get() Reading Raw Bytes Handling Stream Errors Stream State Streams and Exceptions File iostreams A File–Processing Example Open Modes iostream Buffering Seeking in iostreams String iostreams Input String Streams Output string streams Output Stream Formatting Format Flags Format Fields Width, Fill, and Precision An Exhaustive Example Manipulators Manipulators with Arguments Creating Manipulators Effectors iostream Examples Maintaining Class Library Source Code Detecting Compiler Errors A Simple Data Logger Generating Test Data Verifying and Viewing the Data Internationalization Wide Streams Locales Review Session Chapter 20: Runtime Type Identification (RTTI) Runtime Casts The typeid Operator Casting to Intermediate Levels void Pointers Using RTTI with Templates Multiple Inheritance Sensible Uses for RTTI A Trash Recycler Mechanism and Overhead of RTTI Review Session Chapter 21: Multiple Inheritance (MI) Perspective Interface Inheritance Implementation Inheritance Duplicate Subobjects Virtual Base Classes Name Lookup Issues Avoiding MI Extending an Interface Review Session Index
دانلود کتاب انتقال از C به C++: بررسی مشکلات برنامه‌نویسی، چرایی وجود آن‌ها و چگونگی حل آن‌ها توسط C++