We discussed problem of Tower of Hanoi earlier and written a recursive function to solve the problem, Recursive functions take lot of extra memory (New activation record for each call on the stack) (A detailed analysis of recursion is done in this post of mine). Todays question is to write a Non-recursive function to solve […]
Tower of Hanoi is a Mathematical Game. There are 3 pegs (Rods) and number of discs, each of different size, which can be inserted into the rods. All discs are initially inserted into one rod in increasing order (smallest at the top and largest disc at the bottom). You have to move all the discs […]
Those who use languages like C and C++ that support user defined pointer variables, put utmost emphasis on implementing the pointers correctly. And rightfully so, A pointer wrongly handled can be catastrophic. And that’s an understatement 🙂 .
One Definition Rule (ODR) In C++, declaration does not allocate any memory. Its only when an object (or function) is defined that an instance of it is created. The One definition Rule says that there cannot be more that one definition in a single translation unit of C++.
In my opinion, the single biggest addition to C++11 is the Lambda function and expressions (for more features in C++ click here…). Look at the case when you are calling std::sort function, you have to specify the comparator function and then pass that function as an argument to std::sort. In such situations, you may want […]
In my earlier articles on C++, I have written about the automatic type detection, uniform initialization list and Range based for loopin C++11. Earlier we used to use the NULL macro which is synonymous to int zero. This came as an inheritance from C language where 0 plays a double role (as an int and as NULL […]
In my previous articles about C++11 standard I talked about automatic type detection , decltype keyword and uniform initializer list introduced in C++11. Lets see the Range-based for loop today:
In my previous article about the latest C++11 standard I talked about automatic type detection and keyword decltype Today I will take another major enhancement in C++11 called the Initializer List or Uniform Initialization Syntax.
C++11 is the latest version of C++ language originally designed by Stroustrup. I read an interview of him where he said that the latest standard (C++11 or C++0x) feels like a new language. I will be publishing the new features added to the core language and to the STL in following articles in next few […]