Wouldn’t it be great that we could call functions in C++ like this?
create_rectangle(width=10, height=20);
It is definitely more readable than what we usually tend to do:
create_rectangle(10,20);
Is there any reason why the first argument should be the width and the second one the height? Not really, and therefore such function call is difficult to read and is error prone. A strong type enforces that the first argument must actually be of type width and the second one of type height so no error would be possible.
In C++ we can actually achieve something like this:
create_rectangle(Width(10), Height(20));
For this example we could be even more precise and do something like this:
create_rectangle(Width(10m), Height(20m));
The most impressive thing is that in C++ we can achieve this with zero overhead.
Being able to enforce types in our functions and constructor parameters can lead to much readable and less error prone code. In this video we explore the possibilities of a very simple implementation proposed by Jonathan Boccara on this article of his blog.
In the following video we will explain this concept and refactor the constructor for our ftp client library for the Arduino version of the ESP8266.
In the previous article you can find more about the FTP Arduino for ESP8266 client.
i’m even going to order an invicta for myself!
Perfectly indited articles, Really enjoyed studying. Jillie Alisander Bowie
What a information of un-ambiguity and preserveness of valuable familiarity about unexpected emotions. Flore Reynard Heintz