Reduce is a function or method that is used to take the values in an array or a list and apply a function to successive members of the list to produce
Continue ReadingC++: Dijkstra’s Algorithm
Dijkstra's algorithm, conceived by Dutch computer scientist Edsger Dijkstra in 1956 and published in 1959, is a graph search algorithm that solves the
Continue ReadingC++: For Loop
“For” loops are used to make some block of code be iterated a number of times, setting a variable or parameter to a monotonically increasing integ
Continue ReadingC++: Standard Error
A common practice in computing is to send error messages to a different output stream than normal text console messages. The normal messages print
Continue ReadingC++: Call a Foreign-Language Function
Show how a foreign language function can be called from the language. As an example, consider calling functions defined in the C language. Create a
Continue ReadingC++: Identity Matrix
Build an identity matrix of a size known at runtime. An identity matrix is a square matrix, of size n × n, where the diagonal elements are all 1s,
Continue ReadingC++: Catch an Exception Thrown in a Nested Call
Show how to create a user-defined exception and show how to catch an exception raised from several nested calls away. Create two user-defined exc
Continue ReadingC++: Arena Storage Pool
Dynamically allocated objects take their memory from a heap. The memory for an object is provided by an allocator which maintains the storage pool use
Continue ReadingC++: While Loops
Start an integer value at 1024. Loop while it is greater than 0. Print the value (with a newline) and divide it by two each time through the loop.
Continue ReadingC++: Copy and Swap
The copy-and-swap idiom identifies that we can implement a classes copy/move assignment operators in terms of its copy/move constructor and achieve st
Continue Reading