Never forget to delete an array of object created in heap using delete[]. If you forget to do so its really hard to debug especially if you are doing this one in some function some where is your s...
How member function of a class accesses its data member (Technically, how this pointer works)
We all know that there is only one copy of function exist’s for N number of objects or instance of a given class. If you don’t understand the above sentence let me first explain with some example ...
Pointer to a `const` or a `const` pointer
Many of the times we often see some function, where arguments to functions are like const Animal* pAnimal or Animal* const pAnimal. Our head spins for while especially if we are new to cpp (Often h...
Simple way to implement Singleton design pattern without using pointers in c++
A simple way to create a singleton design pattern There are hell lot of example out there online, that how to create a singleton design pattern using pointer and static variable. But here I want t...
pimpl in C++
What is pimpl In simple, pimpl is a c++ technique that removes implementation details of a class from its object representation by placing them in a seperate class and accessing it via an opaque p...
Be careful when using const reference with std::thread / std::async in C++. Otherwise you may be in soup if you don't know this ! :)
From the basics of C and C++. we all know that when we use address-of operator to the variable, then it is an alias of the original variable it points to, and shares the same address. Example: #i...
If you know this in shell script your life is easy
There is one thing which we often get confuse in shell script, especially for those who are new to shell scripting The difference between $var, ${var} and $(var) echo $var echo ${var} echo $(va...
Make your life easy & productive with alias in Linux
When I worked first time with Linux (Ubuntu), I use to remember lot of commands required for my project. In order to make myself productive I started creating either a text file called help.txt or ...
Lambda Expression Cheatsheet in C++/CPP
With out much theory on what is lambda and what is the history behind it. Lets get straight to the point. I see lot of the developers get confused when they want to use lambda, because they feel i...
.bashrc Vs .bash_profile
What is the difference between .bashrc and .bash_profile Sometime many of us get confused whether to place our alias, export’s and init things in .bashrc or **.bash_profile. ** The answer to this...