Bjarne Stroustrup, in 3rd edition (online) of his book "The C++ Programming Language" chapter 2, page 23 (pdf page 34), in a snippet paradigm, defines the function sqrt
. Why does he not just use the one already included in the standard library?
Because sqrt
is an example of a 'good style' procedural function. It takes an input, processes it, and returns the result.
The book is not suggesting that you should write you own, or to copy the definition from the book (which lacks the implementation entirely anyway). The book also isn't demonstrating how to calculate a square root. It is describing the purpose of functions in procedural programming (or that's my interpretation anyway).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With