Tidbits – Streams in C++

If you have watched Red with Bruce Willis you may recall the opening scene. Frank Moses (Bruce Willis) is a retired CIA operative and he is sleeping in his bed. On the night stand next to him there is a clock. The clock is ticking down to 06:00 AM. Just as the clock reaches 06:00 AM, without the need of an alarm, Frank Moses wakes up and calmly walks down to the kitchen to get breakfast. Obviously Frank Moses is a very disciplined and a morning person. Continue reading “Tidbits – Streams in C++”

C++ Tidbits – Exceptions

It is the last Wednesday of January and the Twin Cities of Minneapolis and ST. Paul have been experiencing very cold weather. It is being referred to as a polar vortex. Yesterday in the evening news the weatherman mentioned that our temperature was lower than in the South Pole. One way or another, the thermometer currently reads -29F. We expect even lower temperatures tomorrow reaching -35F. Hopefully the forecast will be amended today. Continue reading “C++ Tidbits – Exceptions”

C++ Tidbits – Generic Programming

What is generic programming? In a nutshell is a mechanism that allows the programmer to delay the data type used in a class / method to run time. If my vague description is not enough you could check here.

The main practical reason for generic programming is to avoid duplication. For example one may have a method or class that would need to be duplicated when using different data types. That grows the code base and may be prone to mistakes after copying and editing. Continue reading “C++ Tidbits – Generic Programming”

C++ Tidbits – Polymorphism

Good morning. It is a relatively cold Saturday in the Twin Cities. For some reason, this winter season has been warmer than usual with very little snow coverage. For example, today the high temperature will be around the freezing point. Some people (like me) like it while others hate it. There is no way to please everyone at once.

In an attempt to review in a systematic way some features of C++ I will be experimenting with polymorphism. In programming languages and type theory, polymorphism is the provision of a single interface to entities of different types or the use of a single symbol to represent multiple different types. To read more about it you may refer here.

Continue reading “C++ Tidbits – Polymorphism”

C++ Tidbits – Inheritance

I am about to complete a course on Neural Networks and Deep Learning. I am amazed at how one gets absorbed into the subject and language (in this case Python). Lately when I am working with C, C++, Java or Python I occasionally use a syntax from a different language.

In this post I will be covering / reviewing Inheritance using C++. Many years ago when I wanted to review C I would pull from my bookshelf the book “C Programming Language” by Brian Kernighan and Dennis Ritchie. During the years I have owned several copies. A few minutes ago I tried to locate my latest copy, but it seems that it grew legs and walked away. For C++ I have … (I guess I have also misplaced it) a book by Bjarne Stroustrup. Given the fact that I want a quick refresher, decided to go over an Advanced C++ Programming course by Mike McMillan. For this post (and a few more that I will write in the next few days) I am using this course as a guide and will be coding C++ on Visual Studio 2017 from Microsoft. Continue reading “C++ Tidbits – Inheritance”

Classes and Objects

I received an email inviting me to solve the Classes and Objects challenge at HackerRank. If interested please take a look at the requirements and give it a try before reading my solution.

The requirements call for the design of a class with two methods. One of them reads grades from standard input while the other computes the total score for a set of five grades. Continue reading “Classes and Objects”