About Me - The Short Story
I am a lonely Python/C++ coder with a background in financial markets and an interest in modern art. I am an application-driven guy, not a computer scientist. Sure I have many gaps in my knowledge, but I strive to do my best to fill them. I keep learning new things, listening to smart guys, correcting my mistakes, and pushing myself to the limits. I enjoy it.
I will use this website both as a blog and as a hub to some of my projects. It is written from scratch in Python's Flask, my favourite web-framework.
Reference vs. copy in a range-based for loop
Understanding the difference between using a reference or a copy of a value is critically important in C++. By default, when we pass a value to a function, it is passed by values, which means we pass a copy of it. The same applied to a for...
c++ 
reference 
range-based for 
Find the value of the n-th element in the Fibonacci sequence
One thing I happen to see many times in interviews, coding challenges, or tutorials on recursion is the Fibonacci sequence. It is a coding evergreen. Fibo is a famous series of numbers where each element is the sum of the two previous. The...
c++ 
algorithms 
recursion 
Getline using std::string vs getline using C-style strings
I have been always fairly confused when dealing with input streams, reading characters, words, or whole lines of text. I was not sure which of the function to use, and why.
One of the things that confused me most was, that there are...
c++ 
string 
Use std::map to calculate density of elements
Often there might be a need to calculate how many times each element from a particular collection appears in that collection. For example, having a string, we might want to how many times each letter appears, or how many times each word...
c++ 
stl 
map 
Demystifying dynamic polymorphism
C++ supports a dynamic (run-time) polymorphic behavior. Polymorphism simply means: one form, many different behaviors – meaning the same line of code, can have completely different outcomes. It is done using pointers
Here I have...
c++ 
object-orientation 
polymorphism 
Map function to a particular value in C++
Imagine a simple task. You have a bunch of values, for example, strings (but it can be any other object, int, float, whatever..) and you a have a bunch of functions, (more generally callables, so it can be a functor, lambda.. etc.) and you...
c++ 
stl 
map 
function 
bind 
Append an element to a C-style array
C-style arrays might be tricky. Even such a trivial task like appending an element might surprise you. It actually surprised me a few times. I do not use raw array in day-to-day programming, I always prefer vector or std::array if I need a...
c++ 
array 
algorithms 
Normalize strings in a container effectively
Having a container of string (vector of emails) and you need to make all the letters uppercase or lowercase or perform whatever else.
You want to do it as effectively as possible, no copying, no raw loops. Quite a typical use...
c++ 
stl 
algorithms 
Convert decimal to a different numerical system
Humans use decimal numbers, computers use binary numbers. A common testing task is to write a function that converts a decimal number to a binary. There is no stl algorithm for that.
But why to stop here, why not to write a function...
c++ 
algorithms 
recursion 
Copy constructors and copy assignement operators in inheritance
Let us see how copy and move constructors and overloaded operator= work with inheritance. The first thing to remember is that copy and move constructors and copy and move assignment operators are not automatically inherited from the base...
c++ 
object-orientation 
inheritance 
Deep copy constructor and assignment operator
This is something I have seen at almost all C++ coding interviews I had.
Having a raw pointer in a class, there is a need for a constructor that copies not only the pointer but the data it points to as well. The same applies to...
c++ 
object-orientation 
constructor 
The quickest way to set up C++ on Windows
Let's say you have a new Windows laptop or a new VPS and you just want a quick, short and sweet set-up so that you can compile and run some C++ code in a minute.
Here is how you do it.
First, download VS Code. When you are...
c++ 
windows 
instalation