Prior to creating a C++ program, one needs to start the C++ IDE. The instructions for starting C++ all depend on the system one is using. This unit assumes that the individual is using the Bloodshed compiler. Incase, one uses a different version ...

Namespace
In C++ two variables with the same name are not possible in the same scope i.e a name given to specific type or function represent one entity in a particluar scope but with namespaces, there is a possibility to create two variables o...

A copy constructor is a special type of constructor by using which we can initialize the data members of a newly created object by existing objects. The compiler provides a default copy constructor.
Syntax of calling a copy constructor is:...

The problem is that a positive integer n is given and check if it is perfect square or not using only addition operation.
// C++ program to check if n is perfect square or not
#include<bits/stdc++.h>
using namespace ...

Edit distance between two strings is said to be one when following changes occur:-
Adding a character.
Deleting a character
A character is changed
// C++ program to check if given two strings are
// at distance one.
#incl...

Virtual function is a member function in base class, which is redefined in the derived class.
Virtual function is declared by using the keyword virtual.
Syntax of virtual function:
class main_Class // denotes the base class of v...

REFERENCE--- A reference variable is initialized first. A reference variable is defined to indicate a variable and that reference variable can't point to the another variable. References can not be NULL.
e.g of reference variable is:...

Foreach loop is another loop which was introduced in C++ 11. The advantage of foreach loop over other loops is that, it can access elements of an array quickly without performing initialization, testing and increment/decrement, the code...

Suppose we want to find the average salary of three employee(A,B,C) without disclosing there individual salary.In order to do this see the following algorithm:
ALGORITHM :
First A will add a random number to it's salary and then tell...

VTABLE- C++ uses a special form of a runtime method binding to implement virtual functions which is called virtual table. Virtual table is a table of functions used to accomplish function calls in a dynamic binding manner. Virtual bin...

Wrapper is generally defined as the packaging, or to bound an object.
A "wrapper class" is used to manage the resources so that it will be crystal-clear to every one. This wraps the resources by simply wrapping the pointer into an in...

Storage classes defines the scope of the variable in the function. Storage class specified for a variable shows that for how long time the variable will remain in the program and which section of the program will have the accessibility of the var...

In C++ scope resolution operator is used to define a function outside a class. If a user has a local variable with same name as global variable and wants to use a global variable the we use the scope resolution operator.
includ...

An Expression is a combination of operators, constants and variables arranged as per rules of language. It may also include function calls which return values. An expression may consist of one or more operators and zero or more operator to produc...

Hello Readers! As we all know a file is a collection of information which is stored on computer's disk and information can be saved to files and then later reused. But, what is the use of file handling why it is required?? Well, let's tak...

C uses malloc() and calloc() function to allocate memory dynamically at runtime. Similarly it uses the function free() to free dynamically allocated memory.
New operator can be used to create objects of any type.It takes the following general ...

In C++ program the compiler converts every statement in machine language of one or more lines, during compiled time. Every line is provided with the unique address. So each function of the program is provided with the unique machine language addr...

free() function and delete operator are used to deallocate the memory a pointer is holding.
free() function is used when the memory is allocated to the pointer by either malloc(),calloc() or realloc() function, whereas delete operator is used wh...

In c++ we use variables to store the value of a number. The type of the value is needed to be declared first because according to that it will allocate the memory to particular variable.
Every variable is assigned with the unique memory address....

Comparison of Exception Handling in C++ and Java
In C++ and Java, keywords like try,catch and throw for exception handling are same,their meaning is also same but exception handling in C++ and Java differ in many ways.
1)In Java only instan...

Can function main() be overloaded in C++?
The main() function can be overloaded in C++ by defining main as member function of a class.Since main is not a reserved word in many programming languages like C++,C# ,java etc, main can be declared ...

If you want to generate permutation of the elements in a range in lexicographic order, then next_permutation function defined in STL algorithm might be helpful for you.
Default template for next_permutation
template <class InputIterator&...

Random shuffle function is used to randomly rearrange the elements in a given range. The random_shuffle function is defined in the STL algorithm.
Template for random_shuffle
template <class InputIterator>
void random_shuffle (Input...

If you want to reverse the order of elements in a given range, then you can use the reverse function defined in the STL algorithm.
Template for reverse
template <class BidirectionalIterator>
void reverse (BidirectionalIterator firs...

If you want to count the presence of a element in a given range, then you can use the count() function defined in the STL algorithm.
It returns the number of variable inside a range whose value is equal to the given number.
Template for count...

If you want to find the presence of a element in a given sorted range, then you can use the binary_search function defined in the STL algorithm.
The range should be sorted in ascending order to perform binary search.
It returns true if el...

There is an interesting way to multiply two positive integer values without using " * " operator and using binary shift operator. The complexity of the program will depends on the number of bits in the binary representation of the multiplier val...

Sort function is used to sort a given range in ascending order. This function is defined in the header algorithm.
There are two version are defined of it.
template< class RandomIt >
void sort( RandomIt first, RandomIt last );
templa...

In C++, Pure virtual method or pure virtual function is a virtual function in which virtual function does not contain a definition inside the function declaration. A pure virtual function/method is declared by assigning a function equal to 0 in d...

Unwinding Stack in C++
Stacks are Last in First Out(LIFO) data structures i.e item last inserted is the first one to be out. C++ perform function calls using stack data structure.The function Call Stack is used for function call/return mechan...

Structures in C++ is a collection of dissimilar data types .Structures is denoted by struct keyword .In structures we can access different data in a single block.It is usually used to keep the track of different kinds of records in a single block...

Friend class in C++
Friend class
Protected and private members of a class cannot be accessed from outside the class in which they are declared. A friend class can access these members of another class in which it is declared as friend.Frien...

C++ supports multiple inheritance unlike java.
In multiple inheritance a class in C++ can have more than one class as it's parent class i.e., it can inherit property from more than one class.
class Area class Perimeter
...

In c++ inheritance is used in a concept of re-usability of code.In Inheritance there is a super/base class and sub/derived class. The base class act as a parent of the derived class. The derived class can inherit the properties of the base class....

Friend Function
These are special functions which can access the private members of a class.
Private and protected data of class can be accessed from a friend function.
Declaration of Friend Function
class className
{
.........

The C++ standard libraries furnish a substantial wind up of input/output.
C++ I/O occurs in streams, which are lineups of data. If data flow from a device like a keyboard to main memory is called input operation and if data flow back from main m...

none_of function is used to test condition on the elements in a range[first,last), it will return true if the test condition is false for all of the element in the range or if the range is empty, else it will return false. To use this function w...

Merge sort is a sorting algorithm that uses "Divide and Conquer" method to sort the array.It divides the array into two halves and then recursively sort the two sub-array and then merge the two sorted sub-arrays into sequence.
Time complexity ...

Overloading :
Same function name with different parameters/signatures.
It is compile time polymorphism.
It occurs in a same class methods.
It is a static/compile time binding.
For e.g:
int sample()
{
cout<<"no argu...

any_of function is used to test condition on the elements in a range[first,last), it will return true if the test condition is true for any of the element in the range, else it will return false or if the range is empty. To use this function we h...