Recursion in C++ Programming

The process of calling a function by itself is called recursion. Recursion is frequently used in mathematics to solve a complex problem by dividing it into simpler problem of same type. Similarly in programming, it can be used to divide a larger problem many simpler problem and solving them individually. The general format of a recursive function is:

Storage Classes in C++ Programming

Storage class of a variable defines the lifetime and visibility of a variable. Lifetime means the duration till which the variable remains active and visibility defines in which module of the program the variable is accessible. There are five types of storage classes in C++. They are:

Namespaces in C++ Programming

Namespace is used to define a scope where identifiers like variables, functions, classes, etc are declared. The main purpose of using a namespace is to prevent ambiguity that may occur when two identifiers have same name.

this pointer in C++ Programming

In C++, this pointer is used to represent the address of an object inside a member function. For example, consider an object obj calling one of its member function say method() as obj.method(). Then, this pointer will hold the address of object obj inside the member function method().

Functions in C++ Programming

Function is a logically grouped set of statements that perform a specific task. For example, a function sort() may sort a group of data. Every C++ program has a function named main() where the execution of the program starts. It is a mandatory function in C++.

Arrays in C++ Programming

Array is a collection of data of same types stored in sequential memory location. It is a linear data structure, where data is stored sequentially one after the other. The elements in an array is accessed using an index. For example, In an array of n elements, the first element has index zero and the last element has index (n-1). Elements with consecutive index (i.e. i and i+1) are stored in consecutive memory location in the system.

Templates in C++ programming

Templates allow programmer to create a common class or function that can be used for a variety of data types. The parameters used during its definition is of generic type and can be replaced later by actual parameters. This is known as the concept of generic programming. The main advantage of using a template is the reuse of same algorithm for various data types, hence saving time from writing similar codes.

Operator overloading in C++ programming

In C++, operators like ‘+’, ‘-‘ have specified functions for native data-types. For example, division operator “/” divides two integers when used as a / b. But, the functions of these operators can also be extended for user-defined data-types as well, this is known as Operator Overloading. For example:

Variables in C++

Variables are the name to memory space in the computer where we can store data of certain types. They are important component of any programming language. In C++, each variable has its type which defines the type of value that can be stored by the variable, size taken by that variable and its range. Some basic types of variables in C++ are int, float, bool, char, etc.