Book description
In just one hour a day, you’ll have all the skills you need to begin programming in C++. With this complete tutorial, you’ll quickly master the basics, and then move on to more advanced features and concepts. Completely updated for the C++14 standard, with a preview of C++17, this book presents the language from a practical point of view, helping you learn how to use C++ to create faster, simpler, and more efficient C++ applications.
Master the fundamentals of C++ and object-oriented programming
Understand how C++ features help you write compact and efficient code using concepts such as lambda expressions, move constructors, and assignment operators
Learn best practices and avoid pitfalls via useful Do’s and Don’ts
Learn the Standard Template Library, including containers and algorithms used in most real-world C++ applications
Test your knowledge and expertise with exercises at the end of every lesson
Learn on your own time, at your own pace
No previous programming experience required
Write fast and powerful C++ programs, compile the source code, and create executable files
Learn object-oriented programming concepts such as encapsulation, abstraction, inheritance, and polymorphism
Use the Standard Template Library’s algorithms and containers to write feature-rich yet stable C++ applications
Learn how automatic type deduction helps simplify C++ code
Develop sophisticated programming techniques using lambda expressions, smart pointers, and move constructors
Master the features of C++ by learning from programming experts
Learn C++ features that allow you to program compact and high-performance C++ applications
Preview what’s new in C++17
Contents at a Glance
Part I: The Basics
Lesson 1: Getting Started
Lesson 2: The Anatomy of a C++ Program
Lesson 3: Using Variables, Declaring Constants
Lesson 4: Managing Arrays and Strings
Lesson 5: Working with Expressions, Statements, and Operators
Lesson 6: Controlling Program Flow
Lesson 7: Organizing Code with Functions
Lesson 8: Pointers and References Explained
Part II: Fundamentals of Object-Oriented C++ Programming
Lesson 9: Classes and Objects
Lesson 10: Implementing Inheritance
Lesson 11: Polymorphism
Lesson 12: Operator Types and Operator Overloading
Lesson 13: Casting Operators
Lesson 14: An Introduction to Macros and Templates
Part III: Learning the Standard Template Library (STL)
Lesson 15: An Introduction to the Standard Template Library
Lesson 16: The STL String Class
Lesson 17: STL Dynamic Array Classes
Lesson 18: STL list and forward_list
Lesson 19: STL Set Classes
Lesson 20: STL Map Classes
Part IV: More STL
Lesson 21: Understanding Function Objects
Lesson 22: Lambda Expressions
Lesson 23: STL Algorithms
Lesson 24: Adaptive Containers: Stack and Queue
Lesson 25: Working with Bit Flags Using STL
Part V: Advanced C++ Concepts
Lesson 26: Understanding Smart Pointers
Lesson 27: Using Streams for Input and Output
Lesson 28: Exception Handling
Lesson 29: Going Forward
Part VI: Appendixes
Appendix A: Working with Numbers: Binary and Hexadecimal
Appendix B: C++ Keywords
Appendix C: Operator Precedence
Appendix D: ASCII Codes
Appendix E: Answers
Table of contents
- About This E-Book
- Title Page
- Copyright Page
- Contents
- Dedication
- Acknowledgments
- About the Author
- We Want to Hear from You!
- Reader Services
- Introduction
-
Part I: The Basics
- Lesson 1. Getting Started
- Lesson 2. The Anatomy of a C++ Program
-
Lesson 3. Using Variables, Declaring Constants
- What Is a Variable?
-
Common Compiler-Supported C++ Variable Types
- Using Type bool to Store Boolean Values
- Using Type char to Store Character Values
- The Concept of Signed and Unsigned Integers
- Signed Integer Types short, int, long, and long long
- Unsigned Integer Types unsigned short, unsigned int, unsigned long, and unsigned long long
- Avoid Overflow Errors by Selecting Correct Data Types
- Floating-Point Types float and double
- Determining the Size of a Variable Using sizeof
- Automatic Type Inference Using auto
- Using typedef to Substitute a Variable’s Type
- What Is a Constant?
- Keywords You Cannot Use as Variable or Constant Names
- Summary
- Q&A
- Workshop
- Lesson 4. Managing Arrays and Strings
-
Lesson 5. Working with Expressions, Statements, and Operators
- Statements
- Compound Statements or Blocks
-
Using Operators
- The Assignment Operator (=)
- Understanding L-values and R-values
- Operators to Add (+), Subtract (-), Multiply (*), Divide (/), and Modulo Divide (%)
- Operators to Increment (++) and Decrement (--)
- To Postfix or to Prefix?
- Equality Operators (==) and (!=)
- Relational Operators
- Logical Operations NOT, AND, OR, and XOR
- Using C++ Logical Operators NOT (!), AND (&&), and OR (||)
- Bitwise NOT (~), AND (&), OR (|), and XOR (^) Operators
- Bitwise Right Shift (>>) and Left Shift (<<) Operators
- Compound Assignment Operators
- Using Operator sizeof to Determine the Memory Occupied by a Variable
- Operator Precedence
- Summary
- Q&A
- Workshop
- Lesson 6. Controlling Program Flow
-
Lesson 7. Organizing Code with Functions
-
The Need for Functions
- What Is a Function Prototype?
- What Is a Function Definition?
- What Is a Function Call, and What Are Arguments?
- Programming a Function with Multiple Parameters
- Programming Functions with No Parameters or No Return Values
- Function Parameters with Default Values
- Recursion—Functions That Invoke Themselves
- Functions with Multiple Return Statements
- Using Functions to Work with Different Forms of Data
- How Function Calls Are Handled by the Microprocessor
- Summary
- Q&A
- Workshop
-
The Need for Functions
- Lesson 8. Pointers and References Explained
-
Part II: Fundamentals of Object-Oriented C++ Programming
-
Lesson 9. Classes and Objects
- The Concept of Classes and Objects
- Keywords public and private
- Constructors
- Destructor
- Copy Constructor
- Different Uses of Constructors and the Destructor
- this Pointer
- sizeof() a Class
- How struct Differs from class
- Declaring a friend of a class
- union: A Special Data Storage Mechanism
- Using Aggregate Initialization on Classes and Structs
- Summary
- Q&A
- Workshop
-
Lesson 10. Implementing Inheritance
-
Basics of Inheritance
- Inheritance and Derivation
- C++ Syntax of Derivation
- Access Specifier Keyword protected
- Base Class Initialization—Passing Parameters to the Base Class
- Derived Class Overriding Base Class’s Methods
- Invoking Overridden Methods of a Base Class
- Invoking Methods of a Base Class in a Derived Class
- Derived Class Hiding Base Class’s Methods
- Order of Construction
- Order of Destruction
- Private Inheritance
- Protected Inheritance
- The Problem of Slicing
- Multiple Inheritance
- Avoiding Inheritance Using final
- Summary
- Q&A
- Workshop
-
Basics of Inheritance
- Lesson 11. Polymorphism
-
Lesson 12. Operator Types and Operator Overloading
- What Are Operators in C++?
- Unary Operators
-
Binary Operators
- Types of Binary Operators
- Programming Binary Addition (a+b) and Subtraction (a-b) Operators
- Implementing Addition Assignment (+=) and Subtraction Assignment (-=) Operators
- Overloading Equality (==) and Inequality (!=) Operators
- Overloading <, >, <=, and >= Operators
- Overloading Copy Assignment Operator (=)
- Subscript Operator ([])
- Function Operator ()
- Move Constructor and Move Assignment Operator for High Performance Programming
- User Defined Literals
- Operators That Cannot Be Overloaded
- Summary
- Q&A
- Workshop
- Lesson 13. Casting Operators
-
Lesson 14. An Introduction to Macros and Templates
- The Preprocessor and the Compiler
- Using Macro #define to Define Constants
- Using #define to Write Macro Functions
-
An Introduction to Templates
- Template Declaration Syntax
- The Different Types of Template Declarations
- Template Functions
- Templates and Type Safety
- Template Classes
- Declaring Templates with Multiple Parameters
- Declaring Templates with Default Parameters
- Sample Template class<> HoldsPair
- Template Instantiation and Specialization
- Template Classes and static Members
- Variable Templates, Also Called Variadic Templates
- Using static_assert to Perform Compile-Time Checks
- Using Templates in Practical C++ Programming
- Summary
- Q&A
- Workshop
-
Lesson 9. Classes and Objects
-
Part III: Learning the Standard Template Library (STL)
- Lesson 15. An Introduction to the Standard Template Library
- Lesson 16. The STL String Class
- Lesson 17. STL Dynamic Array Classes
- Lesson 18. STL list and forward_list
- Lesson 19. STL Set Classes
- Lesson 20. STL Map Classes
-
Part IV: More STL
- Lesson 21. Understanding Function Objects
-
Lesson 22. Lambda Expressions
- What Is a Lambda Expression?
- How to Define a Lambda Expression
- Lambda Expression for a Unary Function
- Lambda Expression for a Unary Predicate
- Lambda Expression with State via Capture Lists [...]
- The Generic Syntax of Lambda Expressions
- Lambda Expression for a Binary Function
- Lambda Expression for a Binary Predicate
- Summary
- Q&A
- Workshop
-
Lesson 23. STL Algorithms
- What Are STL Algorithms?
- Classification of STL Algorithms
-
Usage of STL Algorithms
- Finding Elements Given a Value or a Condition
- Counting Elements Given a Value or a Condition
- Searching for an Element or a Range in a Collection
- Initializing Elements in a Container to a Specific Value
- Using std::generate() to Initialize Elements to a Value Generated at Runtime
- Processing Elements in a Range Using for_each()
- Performing Transformations on a Range Using std::transform()
- Copy and Remove Operations
- Replacing Values and Replacing Element Given a Condition
- Sorting and Searching in a Sorted Collection and Erasing Duplicates
- Partitioning a Range
- Inserting Elements in a Sorted Collection
- Summary
- Q&A
- Workshop
- Lesson 24. Adaptive Containers: Stack and Queue
- Lesson 25. Working with Bit Flags Using STL
-
Part V: Advanced C++ Concepts
- Lesson 26. Understanding Smart Pointers
- Lesson 27. Using Streams for Input and Output
- Lesson 28. Exception Handling
- Lesson 29. Going Forward
-
Part VI: Appendixes
- Appendix A. Working with Numbers: Binary and Hexadecimal
- Appendix B. C++ Keywords
- Appendix C. Operator Precedence
- Appendix D. ASCII Codes
-
Appendix E. Answers
- Answers for Lesson 1
- Answers for Lesson 2
- Answers for Lesson 3
- Answers for Lesson 4
- Answers for Lesson 5
- Answers for Lesson 6
- Answers for Lesson 7
- Answers for Lesson 8
- Answers for Lesson 9
- Answers for Lesson 10
- Answers for Lesson 11
- Answers for Lesson 12
- Answers for Lesson 13
- Answers for Lesson 14
- Answers for Lesson 15
- Answers for Lesson 16
- Answers for Lesson 17
- Answers for Lesson 18
- Answers for Lesson 19
- Answers for Lesson 20
- Answers for Lesson 21
- Answers for Lesson 22
- Answers for Lesson 23
- Answers for Lesson 24
- Answers for Lesson 25
- Answers for Lesson 26
- Answers for Lesson 27
- Answers for Lesson 28
- Answers for Lesson 29
- Index
- Code Snippets
Product information
- Title: Sams Teach Yourself C++ in One Hour a Day, Eighth Edition
- Author(s):
- Release date: December 2016
- Publisher(s): Sams
- ISBN: 9780134539553
You might also like
book
Sams Teach Yourself C++ in One Hour a Day, Seventh Edition
Learn C++ in Just One Hour a Day Completely updated for the C++11 standard, Sams Teach …
book
Sams Teach Yourself C++ in 24 Hours, Sixth Edition
Sams Teach Yourself C++ in 24 Hours is a hands-on guide to the C++ programming language. …
book
C++ for Lazy Programmers: Quick, Easy, and Fun C++ for Beginners
Learn C++ the quick, easy, and “lazy” way. This book is an introductory programming text that …
book
Sams Teach Yourself C++ in One Hour a Day, 9th Edition
The Ninth Edition of Sams Teach Yourself C++ in One Hour a Day Starting with one …