Skip to main content

Posts

Showing posts from September, 2014

Software Adventure - new blog name

I decided to change name of this blog, because I am going to present not only C++ topics here. From today you can expect topics describing problems and features of following domains of software development: C++ programming language features, problems, issues C  programming language features, problems, issues Unix/Linux programming (ex. standard Linux C library, system calls etc.) Embedded Linux programming (problems and solutions related to Embedded Software Development) Software Development Design - Object Oriented Programming, Design Patterns etc. Software Development Life Cycle Sometimes I will also present some articles related to other programming languages like: Python, Java, JavaScript, HTML, CSS etc.  As you noticed range of topics in this blog has been significantly extended. It should this blog more interesting.

C++11 - User-defined literals

C++11 standard provides new way of customized literal constants called user defined literals . Thanks to that user can define own suffixes for standard literals (ex. digits) which defines it better and makes it better readable. Example of such suffixes could be: _meters, _kilograms, _squareMeters etc. For better understanding user-defined literals concept, let's take a look on the below example code: Output of that code is: In point one we can see concept of operator overloading function which should be used in order to define user-defined literals. In our example we are defining suffixex _meters and _squareMeters which will be used for imporve readability of code of calculations based on that units. Point II shows how we can use user-defined literals to assign values to variables. Such usage definitely makes code better readable and easier to understand. Point III, shows how we can use other suffix (_squareMeters) in comparison calculations. As we can see, our units a