Julius Caesar protected his confidential information by encrypting it using a cipher. Caesar’s cipher shifts each letter by a number of letters. If the shift takes you past the end of the alphabet, just rotate back to the front of the alphabet. In the case of a rotation by 3, w, x, y and z… Continue reading
Category: C++
Super Reduced String in C++
Reduce a string of lowercase characters in range ascii[‘a’..’z’]by doing a series of operations. In each operation, select a pair of adjacent letters that match, and delete them. Delete as many characters as possible using this method and return the resulting string. If the final string is empty, return Empty String Example. aab shortens to b in one operation: remove… Continue reading
Print Odd and Even in Separate thread – C++ Multithreading
In this article we will discuss about the how to print odd and even number in separate threads. Let’s see We can also use condition and notify with threads to print odd and even in separate threads.
getline Concept in C++
getline() in C++ is a special convenience function provided by string class for reading line by line. This function reads all characters, including leading whitespaces, until the line delimiter orend-of-file is reached. The line delimiter is extracted but not appended. By default, the line delimiter is the newline character, but you can pass your own… Continue reading
decltype Keyword C++
The decltype keyword takes an expression as argument, and computes the type of that expression,as shown here:int x = 123;decltype(x) y = 456; In this example, the compiler deduces the type of y to be int because that is the type of x.The difference between auto and decltype is that decltype does not strip reference… Continue reading
Namespaces in C++
Namespaces address the problem of naming conflicts between different pieces of code. For example,you might be writing some code that has a function called fun(). One day, you decide to start usinga third-party library, which also has a fun() function. The compiler has no way of knowing whichversion of fun() you are referring to within… Continue reading
Calling C Code from C++ – Mix C and C++
If you have a project which is written in C/C++ where you are seeing the parts of code has been implemented in Cand some part in C++.Then you might have observed that user might have the need to call C function from C++ code and vice-versa. Let’s see how we can do this. Requirement: Compilers… Continue reading
Abstract Factory Pattern C++ Simplified
THE ABSTRACT FACTORY PATTERN A factory in real life constructs tangible objects, such as Furniture. Similarly, a factory in objectoriented programming constructs objects. When you use factories in your program, portions ofcode that want to create a particular object ask the factory for an instance of the object instead ofcalling the object constructor themselves. Abstract… Continue reading