C++ Do while loop

C++ do…while loop Statement A do…while loop is similar to a while loop, except that a do…while loop executes statement within do block first and then check the condition of while. It guaranteed to execute at least one time of statement. In do while loop, while statement …

Read moreC++ Do while loop

C++ Call by Value

C++ Function A function is a set of statements that executes a task. In C++, functions are categorized into two different categories on behalf of argument (parameter) pass. Function with parameter (return_type function_name(paramenter);) Function without parameter (return_type function_name();) Function which …

Read moreC++ Call by Value

C++ Call by Reference

In call by reference function, the action is performed over the actual value pass in the parameter. At the time of function call, we pass the address or reference of value. So that in the call by reference the actual value inside and outside the …

Read moreC++ Call by Reference

C++ Recursion Function

Recursion (recursive) function is such function which call itself again and again. A recursion function call takes within the same function. The condition where the recursive function terminates is called the base case.   Syntax: C++ Recursion Example

Output:

←Prev …

Read moreC++ Recursion Function

C++ Inline function

An inline function is a function that is elaborated in line when it is invoked. When an inline function is called, all the code of inline function gets inserted at the point of function call. It increases the execution time of the …

Read moreC++ Inline function

C++ Friend function

A friend function has the right to access all private and protected members of a class although it is defined outside that class’ scope. Syntax

C++ friend function Example

Output:

  C++ friend function in two different …

Read moreC++ Friend function

Single dimension array

C++ Array An array is a collection of data (elements) of the same data types. The elements of an array are allocated in contiguous memory allocation. Elements of the array are accessed through the index (indices) of that element.   Types of array Single …

Read moreSingle dimension array

Two dimension array

C++ Two dimension (2D) Array Two dimension (2D) array is an array of arrays. It is represented in the form of row and column. The elements of 2D array are accessed through the index of row and column. Declaration of 2D Array …

Read moreTwo dimension array

C++ String

A string is a collection of characters. C++ programming language supports both C string as well as standard C++ library string. In C++, string is an object of std::string class.   C Style String The C style string of C language is also supported …

Read moreC++ String

Single level Inheritance

Inheritance is a feature in which one class inherits the property of another class. A class which inherits the property is called a derived class or subclass or child class and from which derived class inherits property is called as a base class or parent class. Inheritance makes reusability of code, which …

Read moreSingle level Inheritance

Multilevel Inheritance

C++ Multilevel Inheritance Multilevel inheritance is such an inheritance in which a derived class is created from another derived class.   C++ Multilevel Inheritance Example In this example, a base class Student is inherited in a derive class Marks, and the …

Read moreMultilevel Inheritance

Multiple Inheritance

C++ Multiple Inheritance Multiple inheritance is such an inheritance in which a derived class inherits properties of more than one base class.   C++ Multiple Inheritance Example In this example, two base classes Square and Show are inherited in one derived …

Read moreMultiple Inheritance

Hierarchical Inheritance

C++ Hierarchical Inheritance Hierarchical inheritance inherits the property of one base class in more than one derived class.   C++ Hierarchical Inheritance Example

Output:

←Prev Next→

Hybrid Inheritance

C++ Hybrid Inheritance When more than one type of inheritance is combined in single inheritance is called as hybrid inheritance.   C++ Hybrid Inheritance Example

Output:

←Prev Next→

C++ Polymorphism

Polymorphism is an important feature of object-oriented programming. Polymorphism refers to “one name” “multiple forms”. Polymorphism means a program contains the same function name performs different functionality. Polymorphism is classified into two types. These are: Compile time polymorphism Run time …

Read moreC++ Polymorphism

C++ Overloading

C++ Overloading is a condition when two or more members have the same name with different parameter type or a different number of parameter. C++ overloading is two types: Function overloading Operator overloading   C++ Function Overloading When two or …

Read moreC++ Overloading

C++ Overriding

C++ Function Overriding When the base and derive class both contain the same function name and calling the function through derived object invokes derived class function called function overriding. Function overloading is achieved in inheritance. C++ Function Overriding Example

Output: …

Read moreC++ Overriding

C++ Virtual Function

A virtual function is such function which is declared inside the base class and redefined by the derive class. C++ uses a virtual keyword to make a function as a virtual function. The virtual function is always defined in the base class. The concept …

Read moreC++ Virtual Function

C++ Pointer

Pointer is a derived data type that stores the address of a variable. A pointer is used for memory management and dynamic memory allocation. Pointer works on the address of data rather than actual of data. Pointer Declaration

Or

Or

Read moreC++ Pointer

C++ this pointer

‘this’ is a pointer that points to the object for which this function was called. The ‘this’ pointer holds the memory address of the current object. The ‘this’ pointer is implicitly passed to a member function when it is called. Consider the following …

Read moreC++ this pointer