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”

StringStream

I took a look at the StringStream HackerRank challenge. There are two items that one needs to deal with. The first is to parse the coma separated string of integers after it has been assigned to a string stream as suggested by the challenge. Of course one could solve this challenge just parsing the string directly. The second task is to allocate a vector in which to return the integers. At first I just allocated an empty array which I resized each time a new integer had to be inserted. In my final approach I just determined the number of integers by counting the ‘,’s in the string. Continue reading “StringStream”

Linked List – Part VI

I believe that I am finished with the implementation and testing of the DoubleLinkList class using templates in C++. At this point I should be able to start using the class. Hope to get to that sometime this weekend.

Following is the screen capture of a console displayed on my Windows
machine using Visual Studio 2013 while running the test code for double linked lists: Continue reading “Linked List – Part VI”