C++ Programming Tutorial

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:

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.

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.

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.