دسترسی نامحدود
برای کاربرانی که ثبت نام کرده اند
برای ارتباط با ما می توانید از طریق شماره موبایل زیر از طریق تماس و پیامک با ما در ارتباط باشید
در صورت عدم پاسخ گویی از طریق پیامک با پشتیبان در ارتباط باشید
برای کاربرانی که ثبت نام کرده اند
درصورت عدم همخوانی توضیحات با کتاب
از ساعت 7 صبح تا 10 شب
ویرایش:
نویسندگان: Joel Murach. Mary Delamater
سری:
ISBN (شابک) : 1943872279, 9781943872275
ناشر: Mike Murach & Associates
سال نشر: 2018
تعداد صفحات: 770
[802]
زبان: English
فرمت فایل : PDF (درصورت درخواست کاربر به PDF، EPUB یا AZW3 تبدیل می شود)
حجم فایل: 106 Mb
در صورت تبدیل فایل کتاب Murach's C++ Programming به فرمت های PDF، EPUB، AZW3، MOBI و یا DJVU می توانید به پشتیبان اطلاع دهید تا فایل مورد نظر را تبدیل نمایند.
توجه داشته باشید کتاب برنامه نویسی C++ Murach نسخه زبان اصلی می باشد و کتاب ترجمه شده به فارسی نمی باشد. وبسایت اینترنشنال لایبرری ارائه دهنده کتاب های زبان اصلی می باشد و هیچ گونه کتاب ترجمه شده یا نوشته شده به فارسی را ارائه نمی دهد.
C++ اولین بار در سال 1985 منتشر شد و یادگیری آن زبان سختی بود. به این دلیل که برنامه نویسان را ملزم به تسلط بر تکنیک های سطح پایین برای کار با حافظه می کرد. در طول سالها، C++ برای ارائه بسیاری از تکنیکهای سطح بالاتر تکامل یافته است که نوشتن کد موثر C++17 را بسیار آسانتر میکند. اما بیشتر کتابهای ++C با این زبان تکامل پیدا نکردهاند.
اکنون، نویسندگان برتر موراک به این موضوع پرداختهاند و در کل رویکرد تجدیدنظر کردهاند. بنابراین این کتاب از تکنیکهای مدرن بهره میبرد تا یادگیری C++ را آسانتر از همیشه کند. این برنامه به روشی منطقی سازماندهی شده است که شما را با زیرمجموعه ای کاربردی از C++ امروزی شروعی سریع می کند و سپس مهارت های کدنویسی و OOP شما را به سطح حرفه ای ارتقا می دهد. با وجود این پایه، تکنیکهای قدیمیتر را نیز پوشش میدهد، بنابراین شما میتوانید مقدار زیادی از کدهای قدیمی موجود را حفظ کنید، و همچنین با سیستمهای تعبیهشدهای که از تکنیکهای جدیدتر پشتیبانی نمیکنند، کار کنید.
برای اینکه همه چیز قابل مدیریت باشد، این کتاب از قالب متمایز صفحات جفتی Murach استفاده میکند که برنامهنویسان آن را هم برای آموزش و هم برای مرجع مفید میدانند: هر موضوع در یک گستره ۲ صفحهای همراه با نحو، مثالهای کدنویسی ارائه شده است. و دستورالعمل های گلوله ای در صفحه سمت راست و توضیحات اضافی و پرسپکتیو در سمت چپ.
علاوه بر این، این کتاب بیش از 50 مثال برنامه واقعی را برای مطالعه، و همچنین تمرینهایی برای تجربه عملی در اختیار شما قرار میدهد. مثال ها و تمرین هایی از این دست کلید یادگیری هر زبان برنامه نویسی است. اما برای پیدا کردن چنین موارد مؤثری در کتابها و دورههای دیگر که مهارتهای ما را ارائه میکنند، مشکل خواهید داشت.
C++ was first released in 1985, and it was a hard language to learn. That's because it required programmers to master low-level techniques to work with memory. Over the years, C++ has evolved to provide many higher-level techniques that make it much easier to write effective C++17 code. But most C++ books haven't evolved with the language.
Now, Murach's top authors have tackled the subject, rethinking the whole approach. So this book takes advantage of the modern techniques to make it easier to learn C++ than ever before. It's organized in a logical way that gets you off to a fast start with a practical subset of today's C++, and then builds out your coding and OOP skills to the professional level. With that foundation in place, it also covers older techniques so you'll be able to maintain the vast amount of legacy code that's out there, as well as work with embedded systems that don't support the newer techniques.
To make all that manageable, this book uses Murach's distinctive paired-pages format that programmers find so helpful for both training and reference: Each topic is presented in a 2-page spread, with syntax, coding examples, and bulleted guidelines on the righthand page and extra explanation and perspective on the left.
What's more, this book gives you 50+ realistic program examples to study, as well as practice exercises for hands-on experience. Examples and exercises like these are the key to learning any programming language. But you'll have a hard time finding such effective ones in other books and courses, that deliver the skills ours do.
murach's TRAINING & REFERENCE murach's Contents Expanded contents Introduction What this book does Why you’ll learn faster and better with this book What software you need How our downloadable files can help you learn Support materials for instructors and trainers Please let us know how this book works for you Section 1 Essential skills for modern C++ An introduction to C++ programming An overview of programming and C++ Four general-purpose programming languages Four general-purpose programming languages Why it still makes sense to learn C++ today What C++ is used for Description A brief history of C++ C++ ISO standards C++ history Description A quick look at C++ development The user interface for a console application Description The source code for a console application The source code for a console application Description How source code compiles to an executable file How C++ compiles source code into machine language Description Four popular IDEs and compilers Four popular C++ IDEs Features provided by most IDEs Four popular C++ compilers Description How to use Visual Studio for Windows development How to open a project and work with source code Visual Studio with source code displayed in its code editor How to open and close a solution How to open, edit, and save a source code file Description How to compile and run a project Description How to correct a problem with the Windows SDK version How to use code completion and error detection How to use code completion How to use error detection How to create a new project Visual Studio’s dialog for creating a new project Procedure A new project in Visual Studio with some starting source code How to rename and delete files Description How to use Xcode for macOS development How to open a project and work with source code Xcode with source code displayed in its code editor How to open and close a project How to open, edit, and save a source code file Description How to compile and run a project Xcode after compiling and running a console application Description How to use code completion and error detection Xcode’s editor with a code completion list How to use code completion How to use error detection How to create a new project Xcode’s dialogs for creating a new project Procedure A new project in Xcode with some starting source code Procedure (continued) Description Perspective Before you do the exercises in this book Exercise 1-1 Open and run two projects Exercise 1-2 Create a new project How to write your first programs Basic coding skills How to code statements How to code comments A program that consists of statements and comments A block comment that could be coded at the start of a program Description How to code a main() function A main() function with no parameters A main() function with two parameters int main(int argc, char** argv) < A main() function with different brace placement Three standard return values for the main() function Description How to create identifiers Valid identifiers The rules for naming an identifier C++ keywords Additional C keywords Description How to work with numeric variables How to define and initialize variables How to code assignment statements Two built-in data types for working with numbers How to define and initialize a variable in two statements How to define and initialize a variable in one statement An example that uses assignment statements Description Naming recommendations for variables How to code arithmetic expressions How to use the console for input and output How to include header files Common header files of the C++ standard library URL for a complete list of C++ header files A typical way to include header files and make them easily accessible Description How to write output to the console Two objects available from the iostream header How to send a message to the console How to send text and a number to the console Another way to send the same data to the console How to send multiple lines to the console Another way to send multiple lines to the console Description How to read input from the console Another object that’s available from the iostream header How to read one value from the console How to read multiple values from the console How to chain extraction expressions Description The Gallons to Liters program The console The code How to work with the standard library How to call a function Five functions available from the cmath header How to call a function The sqrt() function The pow() function The round() function The floor() function The ceil() function Description How to work with the std namespace A using directive for the std namespace Using declarations for three members of the std namespace tincludetinclude Fully qualified names The console for all three examples Description The Circle Calculator program The console How to generate random numbers Two functions of the cstdlib header for generating random numbers One function of the ctime header Description How to work with char and string variables How to assign values to char and string variables The built-in data type for characters A class that’s available from the string header How to define and initialize a char variable How to include the string header file How to concatenate strings and chars How to append one string to another with the += operator Description How to work with special characters Common escape sequences for special characters String examples Char examples Description How to read strings and chars from the console The getline() function of the iostream header How to use the getline() function to read a full name Member functions of the cin object How to call a member function of an object Syntax Code that pauses until the user presses Enter to continue Description How to fix a common problem with reading strings The data in the cin object after the user enters “1234” How to fix the problem Description The Guest Book program The console The code How to test and debug a program How to test a program How to debug a program The beginning of a file that contains an error The error that’s returned by the compiler The Circle Calculator program with incorrect output Description Debugging tips Perspective Terms Summary Exercise 2-1 Create a Rectangle Calculator program Exercise 2-2 Enhance the Gallons Converter program Exercise 2-3 Enhance the Guest Book program How to make decisions How to get started with if statements How to use the relational operators Relational operators How to test strings and chars for equality Two functions that convert a char to lower or upper case How to make a test for equality of two chars case insensitive Description How to code an if statement The syntax of the if statement An if statement with only an if clause With an else clause With multiple else if clauses Description How to work with braces An if statement without braces An if statement without braces that causes an error An if statement that uses braces to fix the error An if statement with clauses that contain multiple statements Another coding style for brace placement Description The Invoice 1.0 program The console The code More skills for coding if statements How to use the logical operators Logical operators Order of precedence Boolean expressions that use logical operators Description If statements that use the logical operators An if statement that validates the range of a score An if statement that validates the customer type Description How to code nested if statements A table that summarizes the discount rules Nested if statements for applying customer discounts An if statement that gets the same results Description The Invoice 2.0 program The console The code The code (continued) Other ways to make decisions How to use the conditional operator The syntax for a conditional expression A conditional expression How to use a conditional operator to set the value of a variable A statement that uses parentheses to identify the Boolean expression An if statement that performs the same task Description How to code switch statements The syntax of the switch statement A switch statement that uses an int variable named product_id Description More examples of switch statements A switch statement that falls through case labels A switch statement for a menu system Description A switch statement for the Invoice 2.0 program A switch statement for the Invoice application Description Perspective Terms Summary Exercise 3-1 Enhance the Invoice program Exercise 3-2 Enhance the Rectangle Calculator program How to code loops More skills for coding arithmetic expressions How to use arithmetic unary operators The arithmetic unary operators A typical statement that uses the increment operator A typical statement that uses the decrement operator How to prefix an increment operator How to postfix an increment operator How to reverse the value of a number How to perform an arithmetic operation on a character Description How to use the compound assignment operators The compound assignment operators Code that uses the same variable on both sides of the assignment operator Code that uses compound assignment operators to get the same results Description How to work with the order of precedence The order of precedence for arithmetic operations Code that calculates a discounted price Code that calculates the current value of a monthly investment Description How to code while and do-while loops How to code while loops The syntax of the while loop A while loop that calculates the sum of the numbers 1 through 4 A while loop that doesn’t use braces Description More examples of while loops A while loop that continues as long as the user enters ‘y’ A while loop that calculates a future value Code that causes an infinite loop Description How to code do-while loops The syntax of the do-while loop A do-while loop that calculates the sum of the numbers 1 through 4 A do-while loop that doesn’t use braces A do-while loop that calculates a future value A do-while loop that continues as long as the user enters ‘y’ Description The Test Scores program The console The code How to code for loops and nested loops How to code for loops The syntax of the for loop A for loop that calculates the sum of the numbers 1 through 4 A for loop without braces A for loop that adds the numbers 8, 6, 4, and 2 A for loop that calculates a future value Description The Future Value program The console The code How to code nested loops The console Nested loops that print a table of future values How to code break and continue statements How to code break statements How to code continue statements A break statement that exits the loop A continue statement that jumps to the beginning of a loop Description The Guess the Number program The console The code Perspective Terms Summary Exercise 4-1 Enhance the Circle Calculator program Exercise 4-2 Enhance the Future Value program Exercise 4-3 Modify the Guess the Number program How to work with I/O streams and files How to work with input streams An introduction to streams and buffers A program that reads input from and writes output to the console The console The input stream for the first entry The output stream with the user's entries Description How unexpected input can cause problems The program when a user enters all the data on one line The string entered by the user and the extracted values What the program does The program when a user enters the wrong data types at two prompts The two strings entered by the user and the extracted values What the program does Description How to discard data from an input stream How to include the header file for the numericjimits class How to discard all remaining data in the buffer The program updated to clear the buffer after each value is extracted The program when a user enters all the data on one line The program when a user enters the wrong data types at two prompts Description How to detect data input errors The error bits of a stream object The error member functions of a stream object Code that uses the cin object to check the state of a stream A more concise way to extract a value and check the state of a stream Code that uses member functions to check the state of a stream Description How to handle data input errors Code that loops until the user enters a valid number The console Description How to work with output streams An introduction to stream manipulators How to specify the width of a column Common stream manipulators How to include the iomanip header file How to align columns with tabs How to specify the width of a column Description How to right or left justify columns Text data displayed with the default right justification How to left-justify the text with the left manipulator Data that uses left and right justification Description How to format floating-point numbers How to set the number of significant digits How to set the number of decimal places Description The Invoice 3.0 program The console The code The code (continued) How to work with file streams How to read and write a file Three file stream classes Two member functions of the file stream classes How to include the header file for the file stream classes How to write data to a file How to read data from a file How to define a file stream object and open it in one statement How to append data to a file How to use the fstream object to work with files The syntax for the open() member function of a file stream object Common file access flags How to use an ofstream object to append data How to use a fstream object for input and output Description How to check for errors when working with files The data in the file named info.txt A while loop that displays the data in the text file How to handle data conversion errors Description How to read and write delimited data Code that defines a filename Code that writes tab-delimited data to a file Code that reads tab-delimited data from a file Description The Temperature Manager program The console The code The code (continued) How to work with string streams How to use a string stream to handle unexpected data How to include the header file for the string stream classes A data file that contains unexpected data Description The Temperature Analyzer program The console The temps.txt file Description The code The code (continued) Perspective Terms Summary Exercise 5-1 Validate data and create a tab-delimited file Display data from a tab-delimited file Exercise 5-3 Use a string stream How to work with data types, strings, and vectors Basic skills for working with data types The fundamental data types The fundamental data types and their typical sizes and ranges Description Technical notes How to define and initialize variables The assignment operator Statements that define and initialize variables How to define multiple variables in one statement How to define and initialize multiple variables in one statement How to assign the same value to multiple variables How to use the auto keyword to infer the data type based on initial value Description How to define and initialize constants How to define and initialize a constant How to use a constant Description The Light Years Calculator program The console The code More skills for working with data types How to work with type conversion The C++ rules for type coercion The ranking of the data types Examples of type coercion Another way to perform an explicit conversion (not recommended) Description How to work with data type sizes and limits The sizeof operator Syntax The include statement for the numericjimits header file Some of the static members of the numericjimits class What happens when you exceed an integer type’s minimum or maximum Description How to fix problems with floating-point data How to work with vectors How to create a vector and refer to its elements How to include the header file for the vector class The syntax for defining a vector Examples of vector definitions The syntax for referring to an element of a vector How to use the subscript operator to access the elements in a vector Description How to initialize and loop through a vector The syntax for using an initialization list to define and initialize a vector Examples that use an initialization list How to use a for loop to display all the elements in a vector object How to use a range-based for loop to avoid out of bounds access Description How to use member functions of a vector Some member functions of the vector container Statements that use the member functions of a vector How to insert and erase elements Description The Test Scores program The console The code The code (continued) The Temperature Manager program The console The code The code (continued) The code (continued) How to work with strings How to create and loop through a string How to include the header file for the string class How to define a string How to define and initialize a string Another way to define and initialize a string How to capitalize the first letter of a string string name - "grace"; char letter ■ name[OJ; How to compare strings for equality How to use a for loop to convert a string to all uppercase letters How to use a range-based for loop to create a new string of uppercase letters Description How to use basic member functions of a string Some basic member functions of the string class How to remove the last character of a string How to make sure a user has entered a string How to remove all characters from a string Description How to search a string Some member functions for searching strings How to use the find() and rfind() functions How to check if a string contains at least one numeric character How to get the index of the first character that’s not whitespace Description How to work with substrings A member function for getting part of a string How to strip whitespace from the beginning of a string How to get the domain part of an email address Description How to modify a string Some member functions for modifying a string How to insert a string into another string How to delete part of a string How to replace all instances of a placeholder How to replace all instances of one character with another character Description How to check characters within a string Functions for checking the value of a character How to check if a string starts with a lowercase letter How to check if a string contains punctuation Description The Create Account program The console The code The code (continued) The Word Jumble program The console The code The code (continued) Perspective Terms Summary Exercise 6-1 Store the values for future value calculations in vectors How to code functions How to start coding your own functions How to define and call a function The syntax for defining a function A function that doesn’t accept arguments or return data A function that accepts an argument but doesn’t return data A function that accepts two arguments and returns a double value How to define it Description The Miles Per Gallon program The console The code Description How to declare a function The syntax for declaring a function Code that declares functions Code that declares and defines two functions Description When and how to use local and global variables A function that changes a global variable (not recommended) A local variable that shadows a global variable (not recommended) A function that uses a global constant (okay) Description How to plan the functions of a program How to use a hierarchy chart A hierarchy outline for the same program How to build a hierarchy chart Guidelines for creating hierarchy charts The Convert Temperatures program The console The code The code (continued) More skills for coding functions How to use default values for arguments A function definition that has two default values How to call the function with default values A function declaration that has two default values Description How to overload a function An overloaded to_celsius() function Code that calls these functions Description How to use reference variables as parameters How reference parameters work How function calls work Description How to use reference parameters to improve efficiency A function that converts a string to lowercase Description The Temperature Manager program The console The code The code (continued) The code (continued) The code (continued) How to work with header files and namespaces How to create, implement, and use header files The header file named temperature.h The implementation file named temperature.cpp The main.cpp file that uses these functions A header file should not include Description How to define namespaces A header file that declares two functions in a namespace A source code file that defines two functions in a namespace Code that makes it easy to access all functions in a namespace Code that identifies a specific function within a namespace ftinclude #include "temperature.h" Description A header for getting input from the console The console.h file The console.cpp file The console.cpp file (continued) The Future Value program The console The code The code (continued) Perspective Terms Summary Exercise 7-1 Add functions to the Miles Per Gallon program Exercise 7-2 Create a namespace with validation functions How to test, debug, and deploy a program Basic skills for testing and debugging Typical test phases The three types of errors The Future Value program with a logic error The goal of testing The goal of debugging Three test phases The three types of errors that can occur Description Common C++ errors Code that contains syntax errors Common syntax errors Problems with identifiers Problems with values A problem with floating-point numbers How to plan the test runs A simple way to trace code execution Code that traces execution by displaying messages on the console The data that’s displayed on the console Description How to use Visual Studio to debug a program How to set and remove breakpoints Visual Studio with a breakpoint Description How to step through code How to inspect variables A debugging session with Visual Studio Some of the buttons on the Debug toolbar Description How to inspect the stack trace A Visual Studio debugging session with the Call Stack window displayed Description How to use Xcode to debug a program How to set and remove breakpoints Xcode with a breakpoint Description How to step through code How to inspect variables A debugging session with Xcode Some of the buttons on the Debug toolbar Description How to inspect the stack trace An Xcode debugging session with a stack trace displayed Description How to deploy and run a program How to deploy a program How to run a deployed program Typical folder and filename of the executable file How to deploy an executable file Two ways to run the executable file Code that you can add to keep the console open How to use the console to run an executable file on Windows How to use the console to run an executable file on macOS or Linux Description Perspective Terms Summary Exercise 8-1 Test and debug a Test Scores program Exercise 8-2 Test and debug the Future Value program Section 2 More skills as you need them How to work with structures and enumerations Basic skills for working with structures How to get started with structures How to define a structure data type How to define a variable of a structure type How to access the members of a structure object How to create a vector of structure objects and add a structure object to it vector movies; movies.push_back(movie); How to loop through a vector of structure objects Description How to initialize a structure The Movie List 1.0 program The console The code The code (continued) More skills for working with structures How to nest structures An Invoice structure that nests two Date structures Code that uses these nested structures The console Description How to use structures with functions A function that returns a Movie object A function that accepts a Movie object but doesn’t update it A function that accepts a Movie object and updates it Code that uses these functions to work with movie data Another way to update a Movie object Code that uses this function to update a Movie object Description How to compare structures for equality Three Movie objects for comparison What happens if you try to compare structure variables for equality The code How to compare the data members of the Movie objects for equality An if statement that displays a message Code that sets a Boolean variable Description How to work with member functions How to work with member operators A Movie data type with a member function Code that calls the member function of a Movie object How to declare a member function prototype and define it later How to add an operator to a data type Code that uses the equality operator with Movie objects Description The Movie List 2.0 program The console The code The code (continued) The code (continued) The code (continued) How to work with enumerations Basic skills for working with scoped enumerations How to define an enumeration How to access an enumerator How to create a variable for an enumerator How to create and initialize a variable for an enumerator A function that accepts an enumeration as an argument Code that uses the function Description More skills for working with scoped enumerations An enumeration that uses indexes that start with zero Code that converts an integer to its corresponding enumerator Code that gets the corresponding integer of an enumerator Code that uses relational operators with an enumeration How to set the values of the enumerators How to work with char enumerators Description How to work with unscoped enumerations An unscoped enumeration How to access an enumerator How to create and initialize a variable for an enumerator A function that accepts an enumeration as an argument Code that uses the function Problems with unscoped enumerations Description The Monthly Bonus Calculator program The console The code The code (continued) Perspective Terms Summary Exercise 9-1 Use a structure with the Create Account program Exercise 9-2 Use an enumeration with the Movie List program How to work with STL containers and iterators An introduction to STL containers and iterators A summary of STL containers Two types of STL containers Five of the sequence containers Two container adapters Five of the associative containers A URL for more documentation about containers Description A summary of STL iterators Two member functions shared by all STL containers An interval defined by the iterators returned by begin() and end() The six iterator types from lowest to highest Some of the operations provided by iterators Description Basic skills for working with iterators The container that’s used by the examples Two ways to define an iterator How to get iterators that point to the first and third elements How to use the ++ operator in a loop to advance an iterator How to get an iterator that points to the last element How to access the value of the element that an iterator points to Description Member functions shared by the STL containers Some more member functions shared by the STL containers Some examples of the member functions Description How to iterate the data in a container The vector that’s used by the examples How to use a for loop and subscripting to iterate the data in a container How to use a range-based for loop to iterate the data in a container How to use iterators to iterate the data in a container Description More skills for working with vectors Member functions shared by the sequence containers Some member functions shared by the sequence containers Examples Description Member functions of a vector A graphical representation of the contiguous memory of a vector Some member functions of the vector container One of the operators defined by the vector container How to use a list of values to initialize a vector How to use iterators to initialize a vector Description How to set capacity to improve efficiency Code that adds ten elements to an empty vector How to create an empty vector with space for ten elements Description The Movie Rankings 1.0 program The console The code The code (continued) How to work with arrays Basic skills for working with arrays The header file for the array container The syntax for defining an array Two examples that define an array The number of elements in an array must be known at compile time How to use an initialization list How to access the elements in an array How to loop through all of the values in an array Description How to pass an array to a function The console The code How to work with lists An introduction to lists and forward lists A graphical representation of the non-contiguous memory of a list A graphical representation of the pointers of a forward list The header file for the list and forward list containers How to initialize a list and a forward list with a list of values How to use the values of a vector to initialize a list How to assign the values of a vector to a list Description Member functions of a list Some member functions of the list container Examples Description The Movie Rankings 2.0 program The console The code The code (continued) How to work with queues and stacks How to work with queues How to work with stacks Some member functions of the queue container adapter The header file for the queue container adapter An example of working with a queue Some member functions of the stack container adapter The header file for the stack container adapter An example of working with a stack How to work with sets Member functions of associative containers Code examples that work with sets Some member functions shared by the associative containers The header file for the set and multiset containers How to create a set with an initialization list How to find and remove a value from a set Description How to work with maps Member functions and operators of a map Some member functions of the map container One of the operators defined by the map container The header file for the map and multimap containers How to create a map with an initialization list How to display the data in a map Description How to insert key/value pairs and work with values by key The map of strings and ints used by the examples How to insert, read, and write values with the subscript operator How to insert values with the insert() member function How to insert and write values with the insert_or_assign() function How you can accidentally insert a key/value pair with the subscript operator How to use the find() member function to check whether a key is in the map Description The Word Counter program The console The code The code (continued) How to work with nested containers How to work with a vector of vectors How to work with a map of vectors How to work with a vector of vectors How to work with a map of vectors Description Perspective Exercise 10-1 Use a list with the Movie List program Exercise 10-2 Create a program that uses a map Exercise 10-3 Use a multiset and a set with the Word Counter program How to work with STL algorithms An introduction to STL algorithms The relationship between containers, iterators, and algorithms The STL algorithms work with iterators rather than directly with containers Examples that use the same algorithm with five different container types Description How to call an algorithm How to pass a function as an argument A URL that lists all of the STL algorithms The header file for many of the STL algorithms A vector of integers that’s used in the following examples An algorithm that accepts two iterators and doesn’t return a value An algorithm that accepts two iterators plus a third argument and returns a value An algorithm that accepts a smaller range than the sequence in a container An algorithm that returns an iterator An algorithm that accepts a function as an argument Description Note Basic skills for working with algorithms How to use the non-modifying algorithms Non-modifying operations How to count the number of occurrences of an element How to display each element in an interval How to find a specific element in an interval How to search for a range of elements in an interval Description Modifying operations How to replace a value in an interval with another value How to copy the elements of an interval How to remove and erase elements from an interval How to remove and erase in one statement Description How to use the numeric algorithms Minimum/maximum operations A vector of int values used in the following examples How to find the minimum value in an interval How to find the maximum value in an interval How to find the index of the maximum value in an interval Numeric operations The header file for the numeric algorithms How to fill an interval with sequentially increasing values How to total all the values in an interval How to total all the even-numbered values in an interval Sort and binary search operations How to sort an interval in ascending order How to sort an interval in descending order How to sort an interval by length of string Description The Number Cruncher program The console The code The code (continued) More skills for working with algorithms How to use algorithms with intervals of key/value pairs How to display the pairs in a map How to total the values in a map How to count the pairs in a map that meet a criteria Description How to use algorithms with nested containers How to total the values in all the vectors in the map Description More skills for passing functions to algorithms How to work with function templates A function that displays an int value The syntax for creating a function template A function template that can display multiple data types A function template that can display key/value pairs of multiple types template void display(pair p) ( Three container objects used by the following examples Code that calls the function templates directly Description How to work with function objects A function that checks if a pair value is less than 500 A function object that checks if a pair value is less than a varying amount A map of strings and doubles to be used in the following examples Code that uses the function object with the count_if() algorithm Description How to work with lambda expressions The syntax of a lambda expression The parts of a lambda expression How to tell the compiler whether and how to capture variables How to code a lambda expression inline How to store a lambda expression in a variable for reuse How to capture an external variable in a lambda expression How to allow varying data types (C++2014 and later) Description The Uptime Percentage program The console The code The code (continued) Exercise 11-1 Use algorithms with the Test Scores program Exercise 11-2 Use algorithms with the Word Counter program Exercise 11-3 Use a function object and a lambda expression with the Test Scores program How to work with built-in arrays and C strings Basic skills for built-in arrays How to create an array and access its elements The syntax for creating a built-in array Code that creates a built-in array of type int with 7 elements The number of elements in an array must be known at compile time How to access the elements in an array Description How to initialize an array How to loop through an array How to initialize an array How to loop through all the elements in an array Description How to pass an array to a function How to code a function with an array as a parameter What happens to an array when it’s used in an expression Description How to compare and copy arrays How to check whether two arrays are equal How to copy the values of one array to another Description The Test Scores program The console The code The code (continued) How to work with C strings An introduction to C strings How to create a C string How to initialize a partially filled C string Three ways to initialize an empty C string Code that shows the extra element for the null terminator Two char arrays that are not C strings Description How to use C strings with input streams The syntax of the getlineO member function of an input stream object Code that gets a variable-length C string with possible spaces Description Some utility functions for working with C strings The include statement for the cstring header file Some of the functions for working with C strings Code that determines the length of a string Code that concatenates two strings Code that assigns one string to another Code that compares two strings for equality Description How to loop through a C string Code that uses the value returned by strlen() to traverse a C string Code that checks for the null terminator to traverse a C string How to work with a function that accepts a C string Description The Create Account program The console The code The code (continued) The code (continued) Advanced skills for built-in arrays How to search an array Description How to sort an array A function that uses the bubble sort algorithm to sort an array of ints A function that uses the selection sort algorithm to sort an array of ints Description How to use STL algorithms with built-in arrays A built-in array of double values How to use array decay to get a pointer to the first element How to use pointer arithmetic to change the element that's pointed to How to use pointer arithmetic to get a pointer to one past the last element Two ways to pass the pointers to an STL algorithm More examples that use STL algorithms with built-in arrays Description How to create a two-dimensional array Graphical representation of a two-dimensional array How to access the elements in a two-dimensional array How to initialize a two-dimensional array How to process a two-dimensional array with a nested for loop A two-dimensional array of C strings Description The console Description The Top Five program The console The code The code (continued) Note Perspective Terms Summary Exercise 12-1 Use an array with a Product Sales program Exercise 12-2 Use C strings with the Word Jumble program Exercise 12-3 Use a two-dimensional array with the Test Scores program How to work with exceptions How to get started with exceptions A function that doesn’t use exceptions Calling code that displays an invalid result Calling code that uses the return value to check for an error Description How to throw an exception The hierarchy of predefined exception classes The syntax for creating an exception object The syntax of the throw statement A function that throws a predefined exception Calling code that passes an invalid argument Description How to catch an exception The syntax for a try/catch statement that catches an exception The what() function that’s available from all exception objects How to handle an invalid_argument exception A catch clause that handles all predefined exceptions Description A program that catches exceptions The console The code A program that prevents exceptions from being thrown The console The code More skills for working with exceptions How to catch multiple exceptions The syntax for a try statement with multiple catch clauses Code that throws different types of predefined exception objects Code that handles multiple predefined exceptions Description How to rethrow an exception The syntax for rethrowing an exception A function that throws an exception A function that rethrows an exception Description The Temperature Manager program The console for no exceptions The console if load_temps() throws an exception The code for the main() function How to work with custom exceptions Code that throws a string object Code that defines a custom exception object Code that creates a custom exception object and throws it The syntax for a catch clause that catches all exceptions Code that handles multiple custom exceptions Description How exception handling works The call stack after four functions have been called Description Perspective Terms Summary Exercise 13-1 Add exception handling to the Convert Temperatures program Exercise 13-2 Add a custom exception to the Word Counter program Section 3 Object-oriented programming How to define classes An introduction to object-oriented programming A Movie structure that doesn’t provide encapsulation Code that creates an object from the Movie structure and uses it Description A Movie class that provides encapsulation A Movie class Code that creates an object from the Movie class and uses it Description How to define private data members The syntax for defining private and public members A class that places all private members before public members A class that places all public members before private members class Movie ( public: // public members Description How to define getter and setter functions A setter function A setter function that validates data A getter function that returns an int value Code that calls these functions Description The Movie List 1.0 program The console The code The code (continued) More skills for coding member functions How to work with private member functions The declarations for three more functions for the Movie class A private function that converts a string to uppercase A public function that returns the title in uppercase Code that calls the public functions Description How to convert between numbers and strings Three functions for converting between numbers and strings The declarations for more functions for the Movie class A set_year() function that accepts an int value An overload of the set_year() function that accepts a string Code that calls the three public functions Description A default constructor (zero parameters) Another way to code a default constructor (zero required parameters) Three ways to call the default constructor (no arguments) Examples that pass arguments to a constructor An example that creates an object and stores it in a vector Description How to define destructors A destructor An example of a class with a destructor Description How to store a class in header and source files The header and source files for a Movie class The Movie.h file The Movie.cpp file The Movie.cpp file (continued) Description When and how to use inline functions A Movie.h file that uses inline function definitions Pros of inline functions Cons of inline functions Description The Movie List 2.0 program The console The code The code (continued) The code (continued) The code (continued) How to work with UML diagrams An introduction to UML diagrams A UML diagram for the Movie class from figure 14-10 A UML diagram for the Product class from figure 14-15 Description UML diagrams with data types A UML diagram for the Movie class from figure 14-10 A UML diagram for the Product class from figure 14-15 Description A Product class that implements a UML diagram The Product.h file The Product.cpp file The Product Viewer program The console The code The code (continued) How to work with object composition A Die class A UML diagram for a Die class The Die.h file The Die.cpp file A Dice class A UML diagram for two classes that use composition The Dice.h file The Dice.cpp file Description The Dice Roller program The console The code The Pig Dice game The console The code The console The code The code (continued) The code (continued) Perspective Terms Summary Exercise 14-1 Enhance the Dice Roller program Exercise 14-2 Create an object-oriented Convert Temperatures program Exercise 14-3 Create an object-oriented Circle Calculator program How to work with inheritance How to get started with inheritance How inheritance works A UML diagram for three classes that use inheritance Description UML diagramming note How to define a superclass Access modifiers The Product.h file for the Product superclass When coding a superclass... How to define a subclass The syntax for working with subclasses The Book.h file for the Book subclass Another way to code the get_description() function When coding a subclass... How to define another subclass The Movie.h file for the Movie subclass Note How polymorphism works Three definitions of the get_description() function In the Product superclass A function that calls the virtual function Code that passes three different object types to the function Description The Product Viewer program The console The code More skills for working with inheritance How to define an abstract class A pure virtual function in the Product.h file class Product { protected: Two subclasses that override the pure virtual function In the Book subclass Description How to control overriding Two functions that explicitly override another function A function that can’t be overridden A function that explicitly overrides and can’t be overridden In the Book subclass Description How to work with multiple inheritance How multiple inheritance works The DayReader superclass The DayWriter superclass A UML diagram for a class that uses multiple inheritance Description The DayReader superclass The DayWriter superclass The DaylO subclass Code that uses the DaylO subclass The DaylO subclass Code that uses the DaylO subclass When to use inheritance How to use inheritance with custom exceptions The hierarchy for some common exceptions A DaylOError.h file that defines a class for a custom exception Code that throws the custom exception Code that catches a custom exception Description Guidelines for using inheritance It makes sense to use inheritance when... A Dice class that inherits the vector class (not recommended) The Dice.h file Code that uses this Dice class A few problems with this approach Description Perspective Terms Summary Exercise 15-1 Enhance the Product Viewer program Exercise 15-2 Work with abstract classes and control overriding More skills for object- oriented programming How to work with static members How to code static data members and functions The Product class with a static data member and a static function Code in the Product.cpp file that works with the static data member Description How to access static data members and functions How to access a static data member from a class How to access a static data member from an object How to call a static member function from a class How to call a static member function from an object Description The Console class A Console class that provides static functions Code that uses the Console class Code that calls static functions directly from the Console class Code that calls static functions from a Console object The console for both examples Description How to work with a friend function The FuelTank class A FuelTank class Code that uses the FuelTank class Description A friend function that works with two classes The header file for a FuelCan class that declares a friend function The header file for a FuelTank class that declares a friend function The implementation for the friend function Code that uses the friend function Description How to overload operators How to overload arithmetic binary operators The addition operator for the FuelTank class Code that uses the addition operator The subtraction operator for the FuelTank class Code that uses the subtraction operator Description How to overload arithmetic unary operators The prefix increment operator for the FuelTank class Code that uses the prefix increment operator The postfix increment operator for the FuelTank class Code that uses the postfix increment operator Description How to overload relational operators The less than operator for the FuelTank class The greater than operator for the FuelTank class The equality operator for the FuelTank class Code that uses the relational operators Description How to overload the insertion and extraction operators The insertion operator for the FuelTank class The extraction operator for the FuelTank class Code that uses the insertion and extraction operators Description Perspective Terms Summary Exercise 16-1 Enhance the Future Value program Exercise 16-2 Add operators to a Circle object Section 4 Skills for legacy and generic programming How to work with memory and pointers An introduction to memory and pointers How physical memory works A graphical representation of the sequence of bytes in physical memory I I I I I I I I I I I I I I □ How to allocate memory by defining two variables How to allocate memory by defining an array variable How to use the address of operator to get the memory address of an object Description How to define and use pointers Code that defines an int variable and a pointer to that int object A graphical representation of the relationship between these two variables How to display the value stored by the pointer How to use the indirection operator to work with a pointer How to use the member access operator to call a function Description More skills for defining and using pointers The three syntaxes for defining a pointer Three variables used in this figure Three places to code the asterisk when defining a pointer How to define multiple pointers on one line Three ways to define a null pointer How to change the object a pointer points to An error that can occur when changing the object a pointer points to Description How pointer variables compare to reference variables How pointer variables compare to reference variables Define and initialize a regular, reference, and pointer variable Display the underlying value of each variable Display the memory address of each variable Description How to use pointers with functions How and when to pass pointers to functions The square() function with a pointer parameter The square() function with a reference parameter The display_array() function with a pointer parameter for a built-in array When to use a pointer parameter rather than a reference parameter Description How to use the this pointer in a member function A Calculator class whose member functions use the this pointer and return self-references Code that uses the Calculator class Code that uses the Calculator class with function chaining Description The Step Counter 1.0 program The console The code The Step Counter 2.0 program The console The code How to use pointers to work with dynamic memory An overview of the types of storage Types of storage set aside for a program when it starts Automatic storage (stack) Free store (heap) Description How to use the new keyword to allocate free store memory How to use the delete keyword to deallocate free store memory A function that could lead to a memory leak A function that could lead to heap corruption Description How to avoid memory leaks and corruption How to use RAII (Resource Acquisition Is Instantiation) A MyContainer class that uses RAII Code that uses the MyContainer class The console Description How to implement the Rule of Three with RAII The member functions required by the Rule of Three The MyContainer class updated to implement the Rule of Three class MyContainer { private: Description How to implement the Rule of Five with RAII The additional member functions required by the Rule of Five The MyContainer class updated to implement the Rule of Five Description How to work with smart pointers How to include the memory header file Three smart pointers in the memory header (C++11 and later) How to use the make_unique() function (C++14 and later) Code that uses the create_array() function Description The Sensor Analysis program The console The HeapArray.h file The HeapArray.cpp file The main.cpp file More skills for working with pointers How to compare pointers How to use pointer arithmetic How to work with void pointers How to compare pointers How to use pointer arithmetic in an array How to define a void pointer and point to different types How to cast a void pointer to a pointer to a type Description How to use pointers with inheritance The Product hierarchy How to use a superclass pointer to store addresses of subclass objects How to code a function that accepts a superclass pointer How to create a vector of superclass pointers Description How complex compound types work How to define a pointer to a pointer How to dereference a pointer to a pointer How to code a reference to a pointer How to use the const keyword with pointers Examples that use the const keyword with pointers Examples that use compound types Description Perspective Terms Summary Exercise 17-1 Use pointers with built-in arrays Exercise 17-2 Implement the Rule of Three How to work with templates How to work with function templates An overloaded function A function that’s overloaded for two data types Code that calls these functions Description A function template A function template Code that calls this function template The function that’s generated by the first call to the template Description How to code a function template with one type parameter A function that accepts an int value The syntax for a template prefix with a single type parameter Another way to code the same function template A declaration for the first function template How to use type deduction when you call a function template How to explicitly specify the type when you call a function template Description How to code a function template with multiple type parameters Code that calls the function The syntax for a template prefix with multiple type parameters The same function after it has been converted to a function template template void display(K key, V value) { How to use type deduction when you call a function template display("mary", 217); display(1, "Hammer"); How to explicitly specify type when you call a function template Description How to work with class templates How to code a simple class template How to code a more complex class template The header file for the HeapArray class template Description How to use a complex class template Code that uses the HeapArray class template The console Description How to code a function template that works with a class template A function template that works with a class template The console Description The Sensor Analysis program The console The code Perspective Terms Summary Exercise 18-1 Create a function template Exercise 18-2 Add a function to the HeapArray class template Exercise 18-3 Use a class template with a function template How to code custom containers, iterators, and algorithms How to code a custom container How to work with member types Some of the member types provided by the STL containers The size types for two STL containers How to create an alias with the typedef keyword (prior to C++11) How to create an alias with the using keyword (C++11 and later) Code that creates a MyContainer class with a size_type type class MyContainer { public: Code that uses the MyContainer::size_type member type Description The MyVector class declaration The MyVector class declaration The constructor and destructor definitions The constructor and destructor definitions The assignment operator definitions The assignment operator definitions The member function definitions The Task Manager 1.0 program The console The code Description How to code a custom iterator How to work with iterator traits The five iterator traits needed for an iterator class to be STL compliant The iterator category tags How to inherit from std::iterator (deprecated in C++17) Description The Link structure The Link structure Description The Mylterator class The Mylterator class The MyList class declaration The MyList class declaration Description The member function definitions The member function definitions The member function definitions (continued) The Task Manager 2.0 program The console The code Description How to code a custom algorithm The find midpoint() algorithm The find_midpoint() algorithm Code that uses this algorithm with an STL vector Description The Number Cruncher program The console The code The code (continued) Description Terms Summary Exercise 19-1 Test the MyVector class Exercise 19-2 Test the MyList class Exercise 19-3 Create a new custom algorithm Appendix A How to set up Windows for this book How to install the Visual Studio IDE The main page for installing Visual Studio Community The download page for Visual Studio Community How to install the Visual Studio IDE Description How to install the source code for this book The Murach website The folder that contains the Visual Studio projects The subfolders How to download and install the files for this book How to use a zip file instead of a self-extracting zip file Appendix B How to set up macOS for this book How to install the Xcode IDE The download page for Xcode How to install the Xcode IDE Description How to install the source code for this book The Murach website The directory that contains the Xcode projects The subdirectories How to download and install the files for this book A note about right-clicking A note about warnings How the source code makes it easier for Xcode projects to store data in files The source code directory for an Xcode project The working directory for the project The directory that contains the files for most programs in this book The subdirectories Code that has been added to the Xcode source code Description Index A B c D F G H I J K L M N o P Q R s T u V w X 100% Guarantee Programming language books Web development books Database/SQL books We want to hear from you The downloadable files for this book How to install the source code for this book www.murach.com